Algorithm function objects
An algorithm function object (AFO), informally known as niebloid, is a customization point object (CPO)(not necessarily be but for now it is.) that is specified as one or more overloaded function templates.The name of these function templates designates the corresponding algorithm function object.
customization point object (CPO)
Reference:
[C++11][note] C++11 Library Design , initially where the `niebloid` concept comes from when Eric Niebler given this talk; using functor to avoid ADL.
All customization point objects of the same class type are equal. The effects of invoking different instances of that type on the same arguments are equivalent, whether the expression denoting the instance is an lvalue or rvalue, const-qualified or not. However, a volatile-qualified instance is not required to be invocable. Thus, customization point objects can be copied freely and the copies can be used interchangeably.
Let Fn be the type of a customization point object, and Args... be a set of types, if std::declval<Args>()... meet the requirements for arguments to Fn, Fn models:
std::invocable<Fn, Args...>,
std::invocable<const Fn, Args...>,
std::invocable<Fn&, Args...>, and
std::invocable<const Fn&, Args...>.
Otherwise, no function call operator of Fn participates in overload resolution.CPO:
a customization point object is a semiregular, function object (by definition) that exists to handle constrained ADL dispatch for you. ranges::begin, ranges::swap, etc, are customization point objects.
niebloid:
a niebloid is a colloquial name for the algorithms declared in std::ranges that inhibit ADL. The only implementation strategy in standard C++20 for them is to make them function objects, but they are not required to be objects at all (nor are they required to be copyable, etc.) and a possible future language extension would allow them to be implemented as proper function templates. (e.g. [[no_adl]])
concepts:
The semiregular concept specifies that a type is both copyable and default constructible. It is satisfied by types that behave similarly to built-in types like int, except that they need not support comparison with ==.
The regular concept specifies that a type is regular, that is, it is copyable, default constructible, and equality comparable.
It is satisfied by types that behave similarly to built-in types like int, and that are comparable with ==.
Equality preservation
Equality preservation in C++ concepts means that if you give an expression equal inputs,
it must produce equal outputs (the result of the expression and any modified operands).
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.