跳到內容

userconversions

本頁內容尚未翻譯。

def UserConversion.parameters (g : Globals Cpp.constructs) (c : Constructor) : List (Ty Cpp.constructs)

A constructor’s parameters after this.

def UserConversion.referred (t : Ty Cpp.constructs) : Ty Cpp.constructs

What a reference parameter refers to, else the parameter’s type.

def UserConversion.referredAsWritten (t : Ty Cpp.constructs) : Ty Cpp.constructs

What a reference parameter refers to, its const kept (a const reference binds an rvalue too).

def UserConversion.reference (t : Ty Cpp.constructs) : Option Bool

Whether a parameter is a reference: none if not, else whether it is an rvalue reference.

def UserConversion.isExact (c : Constructor * (Bool * Lifted Cpp.constructs)) : Bool

Whether a converting constructor takes exactly the value’s type.

def UserConversion.made (g : Globals Cpp.constructs) (extended : Bool) (target : Ty Cpp.constructs) (node : NodeId) (c : Constructor * (Bool * Lifted Cpp.constructs)) : CheckResult Cpp.constructs (Lifted Cpp.constructs)

The temporary a converting constructor makes from the converted argument (named after the value’s node; one a declared reference binds to is named, so it lives as long as the reference).

def UserConversion.toClass (rules : Rules) (types : TypeExtension Cpp.constructs) (extended : Bool) (g : Globals Cpp.constructs) (n : NodeId) (t : Ty Cpp.constructs) (e : TypedExpr Cpp.constructs) : Option (CheckResult Cpp.constructs (Lifted Cpp.constructs))

A value converted to a class by its converting constructor: a temporary of the class (named after the value’s node, so a declaration it initializes takes it as the object itself; one a declared reference is bound to lives as long as the reference, [class.temporary]p6). None when the value is of the class, or no converting constructor takes it.

def UserConversion.functionName (t : Ty Cpp.constructs) : Option String

The name of the conversion function to the type t, as written (operator double; a class by its name, so no class template’s defaults are needed).

def UserConversion.functionsOf (cls : ClassMembers) : List ClassMember

The conversion functions of a class (its members named operator T), with whether each is explicit.

def UserConversion.fromClass (rules : Rules) (types : TypeExtension Cpp.constructs) (contextual : Bool) (g : Globals Cpp.constructs) (n : NodeId) (t : Ty Cpp.constructs) (e : TypedExpr Cpp.constructs) : Option (CheckResult Cpp.constructs (Lifted Cpp.constructs))

An object of a class converted to a type that is not a class by a conversion function (explicit ones too when contextual, or in a cast): the call’s value, converted as usual. None when the object is not of a class, the type is one, or the object’s class has no such function.

def UserConversion.anyConverts (g : Globals Cpp.constructs) : Bool

Whether some class has a conversion function (none: no operand to convert, and none to check).

def UserConversion.cast (rules : Rules) (types : TypeExtension Cpp.constructs) (checker : Checker Cpp.constructs) (g : Globals Cpp.constructs) (env : Env Cpp.constructs) (n : NodeId) (t : TypeSyntax) (a : Expr) : Option (CheckResult Cpp.constructs (Lifted Cpp.constructs))

A cast with a user-defined conversion: to a class, the class’s construction from the value ([expr.cast]p4: a static_cast, explicit constructors too); of an object of a class to another type, its conversion function’s value ([expr.static.cast]p4, explicit ones too).

def UserConversion.expression (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))

An assignment to an object of a class without operator= (assigned bit for bit) from a value a converting constructor takes: from the temporary it makes; an operator on an object of a class without an operator function for it: on its one conversion function’s value; a cast to a class: the class’s construction; ! of an object of a class without operator!: of its conversion to bool ([expr.unary.op]p9, contextual).