Skip to content

overloading

def Overloading.numbered (name : String) (k : Nat) : String

The name of the k-th function of a name, when there is more than one.

def Overloading.candidates (g : Globals Cpp.constructs) (name : String) : List String

The functions an overloaded name stands for: the signatures named name#k.

def Overloading.objectRank (objectConst : Bool) (this : Ty Cpp.constructs) : Option Nat

How an object matches a member function’s implicit object parameter (its this): none when the object is const and the function is not; 1 when only the function is const (a qualification added), else 0.

def Overloading.ranks (k : Choosing) (g : Globals Cpp.constructs) (n : NodeId) (object : Option Bool) (args : List (TypedExpr Cpp.constructs)) (f : String) : Option (List Nat)

A candidate’s ranks for the arguments (and the object, for a member function), if it is viable: the parameters after the arguments must all have defaults ([over.match.viable]p2.3).

def Overloading.pick (k : Choosing) (g : Globals Cpp.constructs) (env : Env Cpp.constructs) (n : NodeId) (display : String) (candidates : List String) (templated : List String) (object : Option Bool) (args : List Expr) : CheckResult Cpp.constructs String

The function a call chooses among candidates (object: whether the object is const, for member functions); of two as good for every argument, one that is not a template’s instance (templated) is better ([over.match.best]p2.4). A library class’s member function with none viable or two as good is not provided (Mismatch).

def Braced.items (i : Init) : List Init

The items of a braced list’s initializer i (none for any other initializer).

def Braced.textForCharacters (element : TypeSyntax) (xs : List Init) : Bool

Whether a list for elements of the written type element has a string literal for characters ({"abc"} of a string: no element can be made from it, [over.ics.list]p6). This is the part of viability that needs no scope. xs is the list.

def Braced.listed (g : Globals Cpp.constructs) (name : String) (xs : List Init) : Bool

Whether a braced list with items xs initializing the class named name (in the globals g) is its initializer-list constructor’s list (Construction.listFor), not other constructors’ arguments ([over.match.list]p1).

def Braced.target (t : Ty Cpp.constructs) : Ty Cpp.constructs

The type a parameter of type t initializes from a braced list: what a reference refers to, the class of a parameter passed by value (which a call passes by its address, as Construction.rank reads it).

def Braced.against (g : Globals Cpp.constructs) (t : Ty Cpp.constructs) (e : Expr) : Expr

The expression e, a braced list, as the object of the type t it initializes (in the globals g, [dcl.init.list]p3): a class’s T{a, b} (a constructor or an aggregate), a scalar’s single element; any other expression, or a list this does not convert, as it is. A list for a class with an initializer-list constructor stays as it is (unknown where it is checked): its backing array would have to be declared before the expression, which a call’s argument cannot have without moving it out of its order.

def Braced.isAggregate (cls : ClassMembers) : Bool

Whether a class is an aggregate here: it has no constructors (its members are initialized from a list).

def Braced.converts (g : Globals Cpp.constructs) (t : Ty Cpp.constructs) (e : Expr) : Bool

Whether Braced.against converts e, a braced list, for a parameter of type t (in the globals g; it does not for a class with an initializer-list constructor).

def Overloading.isOverloaded (g : Globals Cpp.constructs) (name : String) : Bool

Whether a name is overloaded here: no function has it, and functions name#k do.

def Overloading.addressed (g : Globals Cpp.constructs) (e : Expr) : Option String

The overloaded name an expression uses as a function (f or &f), if it is one.

def Overloading.naming (chosen : String) (e : Expr) : Expr

The expression with the function it names replaced by the chosen one.

def Overloading.ofType (k : Choosing) (g : Globals Cpp.constructs) (t : Ty Cpp.constructs) (name : String) : Option String

The function of an overloaded name whose pointer has the target’s type ([over.over]p1), if there is one.

def Overloading.against (k : Choosing) (g : Globals Cpp.constructs) (env : Env Cpp.constructs) (t : Ty Cpp.constructs) (e : Expr) : Option (CheckResult Cpp.constructs (Lifted Cpp.constructs))

An overloaded name used as a function where a type is expected: the function of that type, checked.

def Overloading.arguments (k : Choosing) (g : Globals Cpp.constructs) (f : String) (args : List Expr) : Option (List Expr)

A call’s arguments with each overloaded name used as a function replaced by the one of its parameter’s type (the others as they are); none when no argument is such a name or the function is not one of the program’s.

def Overloading.withTemplate (k : Choosing) (g : Globals Cpp.constructs) (env : Env Cpp.constructs) (n : NodeId) (f : String) (args : List Expr) : Option (CheckResult Cpp.constructs String)

A call (without template arguments) of a name both ordinary functions and function templates have ([temp.over]): the ordinary ones and, of every template of the name taking that many arguments, the instance for the deduced arguments are the candidates (an instance asked for first when the program does not have it yet, one at a time); templates whose deduction fails are left out. None for any other name.

def Overloading.expression (k : Choosing) (g : Globals Cpp.constructs) (env : Env Cpp.constructs) (e : Expr) : Option (CheckResult Cpp.constructs (Lifted Cpp.constructs))

A call of an overloaded free function: the chosen one’s call, as an expression.

def Overloading.assignmentOf (n : NodeId) (m : NodeId) (lhs : Expr) (value : Expr) : Stmt

The statement at n assigning value to lhs, the assignment at m.

def Overloading.bracedValue (c : StatementContext Cpp.constructs) (t : Ty Cpp.constructs) (b : NodeId) (init : Init) : Expr

The braced list init (at b) as the value of type t (in the context c) it makes (Braced.against).

def Overloading.assignedList (k : Choosing) (g : Globals Cpp.constructs) (env : Env Cpp.constructs) (n : NodeId) (cls : ClassMembers) (xs : List Init) : Option (String * TypeSyntax)

The std::initializer_list<E> an operator= of the class cls takes, with E, when the items xs can make one ([over.ics.rank]p3.1: a list converted to std::initializer_list is better than one converted to the class, so this operator= is the one x = {…} calls, {} included). k chooses, g and env are the declarations and the scope the items are checked in, n is the node of the list.

def Overloading.listAssignment (statements : StatementChecker Cpp.constructs) (c : StatementContext Cpp.constructs) (env : Env Cpp.constructs) (n : NodeId) (m : NodeId) (lhs : Expr) (b : NodeId) (xs : List Init) (list : String * TypeSyntax) : CheckResult Cpp.constructs (TypedStmt Cpp.constructs)

The statement at n assigning the braced list xs (at b) to lhs through an operator= taking list ([over.ass], [dcl.init.list]p5): the backing array declared first (the right operand goes first, [expr.ass]p1), then the call with the std::initializer_list over it, the block’s end destroying the array. An empty list has no array. statements checks the statement it makes, in the context c and the scope env; m is the node of the assignment.

def Overloading.choosesExplicit (k : Choosing) (g : Globals Cpp.constructs) (env : Env Cpp.constructs) (n : NodeId) (cls : ClassMembers) (xs : List Init) : Bool

Whether the constructor copy-list-initialization chooses for the items xs is explicit ([over.match.list]p1: then the list initializes nothing; for x = {…}, no operator= can take it). k chooses, g and env are the declarations and the scope the items are checked in, n is the node of the list, cls the class.

def Overloading.classAssignment (k : Choosing) (statements : StatementChecker Cpp.constructs) (c : StatementContext Cpp.constructs) (env : Env Cpp.constructs) (n : NodeId) (m : NodeId) (lhs : Expr) (b : NodeId) (init : Init) (t : Ty Cpp.constructs) (cls : ClassMembers) : CheckResult Cpp.constructs (TypedStmt Cpp.constructs)

The statement at n assigning the braced list init (at b) to lhs, of the class cls and type t: operator= taking the list when there is one that can (Overloading.listAssignment); else x = T{…} ([expr.ass]p9): the list made into a variable as a declaration of T would make it (an aggregate’s members, an initializer-list constructor) and moved from, as the temporary T{…} would be; any other class is assigned T{…}, its constructors chosen as for a temporary. k chooses, statements checks the statement it makes, in the context c and the scope env; m is the node of the assignment.

def Overloading.bracedAssignment (k : Choosing) (statements : StatementChecker Cpp.constructs) (c : StatementContext Cpp.constructs) (env : Env Cpp.constructs) (n : NodeId) (m : NodeId) (lhs : Expr) (b : NodeId) (init : Init) : CheckResult Cpp.constructs (TypedStmt Cpp.constructs)

The statement at n assigning the braced list init (at b) to lhs, the assignment at m ([expr.ass]p9), checked by k and statements in the context c and the scope env: a scalar’s single element (not narrowed in C++), a class’s by Overloading.classAssignment, a C struct’s members. The right operand is evaluated before the left ([expr.ass]p1).

def Overloading.statement (k : Choosing) (statements : StatementChecker Cpp.constructs) (c : StatementContext Cpp.constructs) (env : Env Cpp.constructs) (s : Stmt) : Option (CheckResult Cpp.constructs (TypedStmt Cpp.constructs))

A call of an overloaded free function as a statement: the chosen one’s call.

def Overloading.parameterKey (aliases : List (String * TypeSyntax)) (t : TypeSyntax) : String

A parameter’s type t as a function’s signature has it ([dcl.fct]p5): an array or a function as the pointer it is adjusted to, its own const dropped, the names of the typedefs aliases expanded (Classes.typeKey).

def Overloading.resultKey (aliases : List (String * TypeSyntax)) (r : Option TypeSyntax) : String

A function’s return type r as a key (v for void), through the typedefs aliases.

def Overloading.freeFunctions (qualifier : String) (items : List Item) : List (String * FunctionDefinition)

The free functions of the items as written, with their names qualified by the namespaces they are in (qualifier: the enclosing namespaces’ prefix).

def Overloading.redefinition (aliases : List (String * TypeSyntax)) (seen : List (String * FunctionDefinition)) (fs : List (String * FunctionDefinition)) : Option (NodeId * Refusal)

The first of the free functions fs defined again with the same parameter types as an earlier one of its name (among seen): a redefinition, or one that differs only in its return type; the typedefs aliases expanded.

def Overloading.redefined (p : Program) : Option (NodeId * Refusal)

The first free function of the program p as written that is defined twice.

def Overloading.renamed (items : List Item) : List Item

The free functions of a name declared more than once, or a function template’s name too ([temp.over]: the template’s instance is chosen among them), renamed f#k in order.

def Overloading.prepare (p : Program) : Program

A program with its overloaded free functions renamed.