XIEITE_FN ()
, XIEITE_FN_LOCAL ()
Defined in header <xieite/fn.hpp>
(header-only:
<xieite/pp/fn.hpp>
)
Allows a shorthand lambda syntax:
XIEITE_FN ($0 + $1 )
which is equivalent to writing:
[](auto&& a , auto&& b ) noexcept (noexcept (a + b )) -> decltype (a + b ) { return a + b ; }
The body of a shorthand lambda has access to a parameter pack
$$
containing all arguments, a template parameter pack $$_
containing all template arguments, variables $0
through $256
which correspond to individual arguments passed to the lambda, and types $0_
through $256_
which correspond to individual template arguments.Accessing a variable or type which does not correspond to an argument (when the number of arguments is not greater than a variable's index or the number of template arguments is not greater than a type's index) results in some unusable value.
Definitions
#0Expands to a lambda with no capture-default.#define XIEITE_FN (...)/* ... */
#1
Expands to a lambda with a reference capture-default.#define XIEITE_FN_LOCAL (...)/* ... */
Example
Output:#include <xieite/fn.hpp>
import xieite ;int main () {auto add_two =XIEITE_FN ($0 +$1 );auto add_all =XIEITE_FN (... +$$ );auto cast =XIEITE_FN (static_cast <$0_ >($0 ));xieite ::dump (add_two (1 ,2 ));xieite ::dump (add_all (1 ,2 ,3 ,4 ,5 ));xieite ::dump (cast .operator ()<int >(6.28318 )); }
3 15 6