references
本頁內容尚未翻譯。
cpp.Ty.referent
Section titled “cpp.Ty.referent”def Ty.referent (t : Ty Cpp.constructs) : Option (Ty Cpp.constructs)The type a reference refers to, if a type is a reference.
cpp.Ty.isRvalueReference
Section titled “cpp.Ty.isRvalueReference”def Ty.isRvalueReference (t : Ty Cpp.constructs) : BoolWhether a type is an rvalue reference.
cpp.Ty.designated
Section titled “cpp.Ty.designated”def Ty.designated (t : Ty Cpp.constructs) : Option (Ty Cpp.constructs)What a variable or a call’s result of a type designates through the address it holds, if the type holds one: a reference’s referent, a class parameter passed by address.
cpp.CppType.same
Section titled “cpp.CppType.same”def CppType.same (a : CppType) (b : CppType) : BoolWhether two of C++’s type tags are the same.
cpp.References.text
Section titled “cpp.References.text”def References.text : TypeText Cpp.constructsHow C++ writes a type in a problem’s details: bool, a class by its name alone, and a reference after what it
refers to (int &, int &&).
cpp.References.plainTypes
Section titled “cpp.References.plainTypes”def References.plainTypes : TypeExtension Cpp.constructsC++‘s types without their classes’ layout: T & resolved to a reference, a class name to its struct (so that a struct’s members of class type complete wherever these types are used alone); references compare by their referents; a reference is laid out as a pointer.
cpp.References.types
Section titled “cpp.References.types”def References.types : TypeExtension Cpp.constructsC++’s types: as References.plainTypes, with a class laid out by the Itanium C++ ABI (cpp.layouts).
cpp.References.designated
Section titled “cpp.References.designated”def References.designated (n : NodeId) (u : Ty Cpp.constructs) (address : TypedExpr Cpp.constructs) : TypedExpr Cpp.constructsWhat an expression of reference type designates: what the address it holds points to.
cpp.References.variableUse
Section titled “cpp.References.variableUse”def References.variableUse (n : NodeId) (t : Ty Cpp.constructs) (x : DeclId) : Option (TypedExpr Cpp.constructs)A variable of reference type: what it refers to.
cpp.References.memberUse
Section titled “cpp.References.memberUse”def References.memberUse (n : NodeId) (e : TypedExpr Cpp.constructs) : Option (TypedExpr Cpp.constructs)A member of reference type (the member as the core reaches it): what it refers to, through the address the member holds; the object’s constness does not reach it ([expr.ref]p6.1).
cpp.References.conditional
Section titled “cpp.References.conditional”def References.conditional (checker : Checker Cpp.constructs) (g : Globals Cpp.constructs) (env : Env Cpp.constructs) (asLvalue : Bool) (e : Expr) : Option (CheckResult Cpp.constructs (Lifted Cpp.constructs))c ? a : b with a and b lvalues of the same type and constness is an lvalue of it ([expr.cond]p4): *(c ? &a : &b), which evaluates c and one of them as the conditional does (only when both check as lvalues, so their
addresses can be taken). None for any other expression.
cpp.References.xvalueOf
Section titled “cpp.References.xvalueOf”def References.xvalueOf (n : NodeId) (u : Ty Cpp.constructs) (address : TypedExpr Cpp.constructs) : TypedExpr Cpp.constructsAn xvalue: the object an address points to, marked as one whose resources may be taken.
cpp.References.isXvalue
Section titled “cpp.References.isXvalue”def References.isXvalue (e : TypedExpr Cpp.constructs) : BoolWhether an expression is an xvalue: an object reached through an address marked expiring, or a member of one
([expr.ref]p6.2).
cpp.References.isRvalue
Section titled “cpp.References.isRvalue”def References.isRvalue (e : TypedExpr Cpp.constructs) : BoolWhether an expression is an rvalue: not an lvalue, an xvalue, or a temporary object (a class prvalue, kept in the variable named for its node).
cpp.References.callResult
Section titled “cpp.References.callResult”def References.callResult (n : NodeId) (t : Ty Cpp.constructs) : Option (TypedExpr Cpp.constructs)A call’s result of reference type (kept in a temporary named for the node): what it refers to; an xvalue for an rvalue reference.
cpp.References.callAsLvalue
Section titled “cpp.References.callAsLvalue”def References.callAsLvalue (checker : Checker Cpp.constructs) (g : Globals Cpp.constructs) (env : Env Cpp.constructs) (n : NodeId) (e : Expr) : CheckResult Cpp.constructs (Lifted Cpp.constructs)A call e (at the node n, checked by checker in the globals g and the scope env) used as an lvalue: one whose
result is a reference is what it refers to; one whose result is an object of a class is that object, materialized in
the temporary that keeps the result ([class.temporary]p2: a member function can be called on it); any other call is
not an lvalue.
cpp.References.callLvalue
Section titled “cpp.References.callLvalue”def References.callLvalue (checker : Checker Cpp.constructs) (g : Globals Cpp.constructs) (env : Env Cpp.constructs) (e : Expr) : Option (CheckResult Cpp.constructs (Lifted Cpp.constructs))The call e used as an lvalue (References.callAsLvalue, checked by checker in the globals g and the scope
env), with template arguments written too (get<1>(t) = 9); none when e is not a call.
cpp.References.addressFor
Section titled “cpp.References.addressFor”def References.addressFor (n : NodeId) (u : Ty Cpp.constructs) (e : TypedExpr Cpp.constructs) : TypedExpr Cpp.constructsThe address a reference to u holds for an lvalue.
cpp.References.temporary
Section titled “cpp.References.temporary”def References.temporary (extended : Bool) (n : NodeId) (u : Ty Cpp.constructs) (value : TypedExpr Cpp.constructs) : Lifted Cpp.constructsAn rvalue bound to a const reference: kept in a temporary named for the node, its address bound; a temporary that lives as long as the reference has a name (one without ends with the full expression).
cpp.References.extending
Section titled “cpp.References.extending”def References.extending (n : NodeId) (u : Ty Cpp.constructs) (y : DeclId) (e : TypedExpr Cpp.constructs) : CheckResult Cpp.constructs (Lifted Cpp.constructs)A temporary of the referred class (a call’s result, the variable y) bound to a reference that extends it ([class.temporary]p6): the temporary becomes one that lives as long as the reference, without a copy, and the call’s is handed over, so the full expression’s end does not destroy it.
cpp.References.spelled
Section titled “cpp.References.spelled”def References.spelled (t : Ty Cpp.constructs) : StringHow a type is written in C++’s messages: a class by its name, any other as the core writes it.
cpp.References.bind
Section titled “cpp.References.bind”def References.bind (types : TypeExtension Cpp.constructs) (user : Converting) (g : Globals Cpp.constructs) (rules : Rules) (p : Platform) (extended : Bool) (rvalue : Bool) (n : NodeId) (u : Ty Cpp.constructs) (given : TypedExpr Cpp.constructs) : CheckResult Cpp.constructs (Lifted Cpp.constructs)A value bound to a reference to u (an object of a class derived from u’s as its base subobject,
cpp.inheritance): an lvalue or an xvalue of the same type by its address (not dropping const),
an lvalue only to an lvalue reference; a prvalue only to a const or an rvalue reference, through a temporary
converted to u ([dcl.init.ref]p5). A base that is ambiguous or may not be reached here is an error.
cpp.References.bound
Section titled “cpp.References.bound”def References.bound (types : TypeExtension Cpp.constructs) (user : Converting) (g : Globals Cpp.constructs) (rules : Rules) (p : Platform) (extended : Bool) (rvalue : Bool) (n : NodeId) (u : Ty Cpp.constructs) (given : TypedExpr Cpp.constructs) : CheckResult Cpp.constructs (Lifted Cpp.constructs)References.bind once the base (when the value is of a derived class) may be reached.
cpp.Converting
Section titled “cpp.Converting”def Converting : TypeA user-defined conversion to a class (whether the temporary is extended, the tables, the node, the class’s type, the value), if one applies.
cpp.References.conversions
Section titled “cpp.References.conversions”def References.conversions (rules : Rules) (user : Converting) : ConversionExtension Cpp.constructsC++’s conversions: a value bound to a reference.
cpp.References.declaration
Section titled “cpp.References.declaration”def References.declaration (rules : Rules) (user : Converting) (checker : Checker Cpp.constructs) (g : Globals Cpp.constructs) (env : Env Cpp.constructs) (n : NodeId) (x : DeclId) (name : String) (t : Ty Cpp.constructs) (i : Option Init) : Option (CheckResult Cpp.constructs (TypedStmt Cpp.constructs))A declaration of reference type: it must be initialized by an expression ([dcl.init.ref]p1), bound with a temporary that lives as long as the reference.
cpp.TypeSyntax.referent
Section titled “cpp.TypeSyntax.referent”def TypeSyntax.referent (t : TypeSyntax) : Option TypeSyntaxThe written type a reference refers to (const kept on it), if a written type is a reference.
cpp.References.sizeof
Section titled “cpp.References.sizeof”def References.sizeof (checker : Checker Cpp.constructs) (g : Globals Cpp.constructs) (env : Env Cpp.constructs) (e : Expr) : Option (CheckResult Cpp.constructs (Lifted Cpp.constructs))sizeof of a reference type is the size of what it refers to ([expr.sizeof]p2); a reference’s storage is still a pointer’s.
cpp.TypeSyntax.isReference
Section titled “cpp.TypeSyntax.isReference”def TypeSyntax.isReference (t : TypeSyntax) : BoolWhether a written type is a reference (a variable of it refers to memory elsewhere, for the effect summaries).
cpp.References.cast
Section titled “cpp.References.cast”def References.cast (rules : Rules) (types : TypeExtension Cpp.constructs) (checker : Checker Cpp.constructs) (g : Globals Cpp.constructs) (env : Env Cpp.constructs) (e : Expr) : Option (CheckResult Cpp.constructs (Lifted Cpp.constructs))static_cast<T &&>(e) ([expr.static.cast]p3): an xvalue of the object e designates (of T, or of a class derived
from T’s as its base subobject); a prvalue is kept in a temporary first, which ends with the full expression.
static_cast<T &>(e) is the lvalue a reference T &t(e); would bind ([expr.static.cast]p4; as a reference collapsed
from U & && in a template’s instance).
cpp.References.pointed
Section titled “cpp.References.pointed”def References.pointed (t : Ty Cpp.constructs) : Option (Ty Cpp.constructs)What a pointer or an array points to (an array as the pointer it decays to), if the type is one.
cpp.References.constCast
Section titled “cpp.References.constCast”def References.constCast (types : TypeExtension Cpp.constructs) (checker : Checker Cpp.constructs) (g : Globals Cpp.constructs) (env : Env Cpp.constructs) (n : NodeId) (t : TypeSyntax) (a : Expr) : CheckResult Cpp.constructs (Lifted Cpp.constructs)const_cast<T>(a) ([expr.const.cast]): to T &, the lvalue a is with its const taken away (a must be an lvalue
of T’s type, cv aside, p4); to T *, the pointer (to T’s type, cv aside, p3; an array decays to one first, p1); to
anything else it is not allowed.
cpp.References.reinterpretCast
Section titled “cpp.References.reinterpretCast”def References.reinterpretCast (types : TypeExtension Cpp.constructs) (checker : Checker Cpp.constructs) (g : Globals Cpp.constructs) (env : Env Cpp.constructs) (n : NodeId) (t : TypeSyntax) (a : Expr) : CheckResult Cpp.constructs (Lifted Cpp.constructs)reinterpret_cast<T>(a) ([expr.reinterpret.cast]): to T &, the lvalue a seen as a T (p11, as
*reinterpret_cast<T *>(&a)); to T *, a pointer (or an array) as a pointer to T (p7); to its own type, a’s value
(p2). It may not cast away constness (p2); between pointers and integers (p4, p5) the result is the implementation’s,
not modeled.