ranges
cpp.Ranges.rangeFor
Section titled “cpp.Ranges.rangeFor”def Ranges.rangeFor (k : Constructing) (c : StatementContext Cpp.constructs) (env : Env Cpp.constructs) (n : NodeId) (x : DeclId) (name : String) (t : TypeSyntax) (byRef : Bool) (r : Expr) (body : Stmt) : CheckResult Cpp.constructs (TypedStmt Cpp.constructs)The range-based for at node n, for (t name : r) body with x the element’s declaration (bound to it when byRef),
checked by k in the context c and the scope env ([stmt.ranged]p1): the range kept by its address, its begin and end
once (an array’s first element and one past its last; a class’s begin() and end()), then the loop over them, each
element declared from *begin (or bound to it). A braced list as r is first made an array (Ranges.bracedRange).
cpp.Ranges.bracedElements
Section titled “cpp.Ranges.bracedElements”def Ranges.bracedElements (k : Constructing) (c : StatementContext Cpp.constructs) (env : Env Cpp.constructs) (n : NodeId) (items : List Init) : CheckResult Cpp.constructs (List (Lifted Cpp.constructs))The items of a braced list, each checked by k in the context c and the scope env, in order (a braced list’s elements are sequenced, [dcl.init.list]p4); a nested list has no type to deduce from ([temp.deduct.call]p1): rejected at n.
cpp.Ranges.bracedRange
Section titled “cpp.Ranges.bracedRange”def Ranges.bracedRange (k : Constructing) (c : StatementContext Cpp.constructs) (env : Env Cpp.constructs) (n : NodeId) (items : List Init) : CheckResult Cpp.constructs (Env Cpp.constructs * Lifted Cpp.constructs)A braced list of items as the range of the loop at n, checked by k in the context c: auto &&__range = {…} is a
std::initializer_listRanges.listArray). The array is declared before the loop, which goes over it as over any array: the
scope env with the array, and the array as an lvalue.
cpp.Ranges.listArray
Section titled “cpp.Ranges.listArray”def Ranges.listArray (k : Constructing) (p : Platform) (env : Env Cpp.constructs) (n : NodeId) (ls : List (Lifted Cpp.constructs)) : CheckResult Cpp.constructs (Env Cpp.constructs * Lifted Cpp.constructs)The array of const E that the checked elements ls of a braced list make, declared at n on the platform p, with E deduced alike from every element by k (none deduced from an empty list or elements of different types: rejected at n); the scope env with the array, and the array as an lvalue.
cpp.Ranges.statement
Section titled “cpp.Ranges.statement”def Ranges.statement (k : Constructing) (c : StatementContext Cpp.constructs) (env : Env Cpp.constructs) (s : Stmt) : Option (CheckResult Cpp.constructs (TypedStmt Cpp.constructs))C++’s range-based for, when s is one: checked by k in the context c and the scope env.