Skip to content

references

def Ty.referent (t : Ty Cpp.constructs) : Option (Ty Cpp.constructs)

The type a reference refers to, if a type is a reference.

def Ty.isRvalueReference (t : Ty Cpp.constructs) : Bool

Whether a type is an rvalue reference.

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.

def CppType.same (a : CppType) (b : CppType) : Bool

Whether two of C++’s type tags are the same.

def References.text : TypeText Cpp.constructs

How 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 &&).

def References.plainTypes : TypeExtension Cpp.constructs

C++‘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.

def References.types : TypeExtension Cpp.constructs

C++’s types: as References.plainTypes, with a class laid out by the Itanium C++ ABI (cpp.layouts).

def References.designated (n : NodeId) (u : Ty Cpp.constructs) (address : TypedExpr Cpp.constructs) : TypedExpr Cpp.constructs

What an expression of reference type designates: what the address it holds points to.

def References.variableUse (n : NodeId) (t : Ty Cpp.constructs) (x : DeclId) : Option (TypedExpr Cpp.constructs)

A variable of reference type: what it refers to.

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).

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.

def References.xvalueOf (n : NodeId) (u : Ty Cpp.constructs) (address : TypedExpr Cpp.constructs) : TypedExpr Cpp.constructs

An xvalue: the object an address points to, marked as one whose resources may be taken.

def References.isXvalue (e : TypedExpr Cpp.constructs) : Bool

Whether an expression is an xvalue: an object reached through an address marked expiring, or a member of one ([expr.ref]p6.2).

def References.isRvalue (e : TypedExpr Cpp.constructs) : Bool

Whether 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).

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.

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.

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.

def References.addressFor (n : NodeId) (u : Ty Cpp.constructs) (e : TypedExpr Cpp.constructs) : TypedExpr Cpp.constructs

The address a reference to u holds for an lvalue.

def References.temporary (extended : Bool) (n : NodeId) (u : Ty Cpp.constructs) (value : TypedExpr Cpp.constructs) : Lifted Cpp.constructs

An 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).

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.

def References.spelled (t : Ty Cpp.constructs) : String

How a type is written in C++’s messages: a class by its name, any other as the core writes it.

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.

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.

def Converting : Type

A user-defined conversion to a class (whether the temporary is extended, the tables, the node, the class’s type, the value), if one applies.

def References.conversions (rules : Rules) (user : Converting) : ConversionExtension Cpp.constructs

C++’s conversions: a value bound to a reference.

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.

def TypeSyntax.referent (t : TypeSyntax) : Option TypeSyntax

The written type a reference refers to (const kept on it), if a written type is a reference.

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.

def TypeSyntax.isReference (t : TypeSyntax) : Bool

Whether a written type is a reference (a variable of it refers to memory elsewhere, for the effect summaries).

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).

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.

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.

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.