跳到內容

standardfunctions

本頁內容尚未翻譯。

def StandardFunctions.called (items : List Item) : List String

The names of the functions the items call (each call once, in order; one walk over the items).

def StandardFunctions.calls (called : List String) (f : String) : Bool

Whether a function of a name is among the called ones.

def StandardFunctions.fresh (head : String) (it : Item) : Item

A generated item with fresh nodes under a head.

def StandardFunctions.choosing (name : String) (secondWins : Expr -> Expr -> Expr) : Item

template <typename T> const T &std::max(const T &a, const T &b) (or min): the second when it wins.

def StandardFunctions.abs (t : TypeSyntax) (floating : Bool) : Item

T std::abs(T x) for the type t: the integer’s magnitude (as C’s abs, undefined for the most negative), a floating value’s fabs (long double’s is not decided: fabs of a long double, CheckDialect.wantsLongDoubleMath).

def StandardFunctions.classifying (name : String) : Item

bool std::isnan(long double x), bool std::isinf(long double x) ([c.math.fpclass]) for the classification name: a NaN is the value not equal to itself; an infinity is a value equal to itself whose difference with itself is a NaN (inf - inf). A float, a double or an integer is converted to long double first, which keeps its value (long double holds every double), so one function serves the overloads.

def StandardFunctions.removeReference : List Item

std::remove_reference<T>::type ([meta.trans.ref]) as the standard defines it: a class template whose member type is T, with partial specializations for T & and T &&.

def StandardFunctions.removed : TypeSyntax

The referred type of T, typename std::remove_reference<T>::type.

def StandardFunctions.move : Item

template <class T> typename remove_reference<T>::type &&std::move(T &&t): an xvalue of what t refers to ([forward]p8).

def StandardFunctions.forward : Item

template <class T> T &&std::forward(typename remove_reference<T>::type &t): t as T says it was passed, an lvalue for T = U & and an xvalue otherwise ([forward]p2; T is written, not deduced).

def StandardFunctions.classifications : List String

The classifications C++ has as functions.

def StandardFunctions.math : List String

The functions that are C’s under std: all of C’s <math.h> the core has.

def StandardFunctions.generated : List String

The functions this branch generates when called (std’s own templates and overloads).

def StandardFunctions.fromC : List String

C’s library functions written with std:: (, , , declare them in std too, C++17 [headers]p4): the C function, but for the names this branch has its own of (std::abs is C++’s overloads, std::isnan C++’s function).

def StandardFunctions.provided : List String

The functions this branch provides under std, by their unqualified names: those it generates when called, the classifications, and C’s <math.h> (a using namespace std; makes them visible without std::).

def Braced.elements (xs : List Init) : Option (List Expr)

The expressions of a braced list’s elements, when each is an expression (no braces or designators inside).

def StandardFunctions.writesItself (e : Expr) : Bool

Whether an expression changes something itself (an assignment, an increment, input, new): as the argument of a call it is unsequenced with the other arguments’ accesses, while a braced list’s elements are sequenced.

def StandardFunctions.extremesOfList (e : Expr) : Expr

min({a, b, c}) and max({…}) in e (their initializer_list versions, [alg.min.max]) as the two-argument ones from the left, min(min(a, b), c): the same value, the first of equal ones as min_element gives. The list evaluates its elements in order and the nested calls’ arguments are indeterminately sequenced: with calls in the elements the value is the same when their effects do not conflict, and the check reports the order when they do (never a wrong answer). An element that changes something itself (StandardFunctions.writesItself) would be unsequenced there: that list is left as it is.

def StandardFunctions.prepare (p : Program) : Program

The std functions the items call, generated, and the items with std’s calls as C’s.

def StandardFunctions.bitwise (g : Globals Cpp.constructs) (t : Ty Cpp.constructs) : Bool

Whether a type is exchanged bit for bit: no class, or a class without a copy constructor or destructor (its moves are bit for bit too).

def StandardFunctions.hiddenVariable (m : NodeId) (hidden : DeclId) : Expr

The hidden variable a swap holds a copy in.

def StandardFunctions.swap (types : TypeExtension Cpp.constructs) (checker : Checker Cpp.constructs) (statements : StatementChecker Cpp.constructs) (c : StatementContext Cpp.constructs) (env : Env Cpp.constructs) (n : NodeId) (m : NodeId) (a : Expr) (b : Expr) : CheckResult Cpp.constructs (TypedStmt Cpp.constructs)

std::swap(a, b) as a statement.

def StandardFunctions.explicitSwap (types : TypeExtension Cpp.constructs) (checker : Checker Cpp.constructs) (statements : StatementChecker Cpp.constructs) (c : StatementContext Cpp.constructs) (env : Env Cpp.constructs) (n : NodeId) (m : NodeId) (w : TypeSyntax) (a : Expr) (b : Expr) : CheckResult Cpp.constructs (TypedStmt Cpp.constructs)

std::swap<W>(a, b), the template argument written ([temp.arg.explicit]): with T = W the first overload takes two lvalues of type W (T &), the array overload two arrays of W of the same length (T (&)[N], N deduced); either is the swap of std::swap(a, b). W const (not move-assignable, [utility.swap]p1) or an argument of another type matches neither: no matching function. A reference written as W is not done. The statement n calls at the node m with w written as W, checked by checker and statements (the types by types) in the context c and the scope env.

def StandardFunctions.statement (types : TypeExtension Cpp.constructs) (checker : Checker Cpp.constructs) (statements : StatementChecker Cpp.constructs) (c : StatementContext Cpp.constructs) (env : Env Cpp.constructs) (s : Stmt) : Option (CheckResult Cpp.constructs (TypedStmt Cpp.constructs))

The std functions checked as statements: std::swap(a, b) and std::swap<T>(a, b) as the statement s, checked by checker and the statements’ checker (the types by types) in the context c and the scope env; none for any other.