libsigc++: Lambdas
libsigc++ ships with basic lambda functionality and the sigc::group adaptor, which uses lambdas to transform a functor's parameter list. More...
Modules | |
group() | |
sigc::group() alters an arbitrary functor by rebuilding its arguments from one or more lambda expressions. |
Classes | |
struct | sigc::lambda_base |
A hint to the compiler. More... | |
struct | sigc::lambda< T_type > |
Lambda type. More... |
Detailed Description
libsigc++ ships with basic lambda functionality and the sigc::group adaptor, which uses lambdas to transform a functor's parameter list.
The lambda selectors sigc::_1, sigc::_2, ..., sigc::_9 are used to select the first, second, ..., nineth argument from a list.
- Examples:
Operators are defined so that, for example, lambda selectors can be used as placeholders in arithmetic expressions.
- Examples:
If your compiler supports C++11 lambda expressions, they are often a good alternative to libsigc++'s lambda expressions. The following examples are equivalent to the previous ones.
[] (int x, int, int) -> int { return x; }(10,20,30); // returns 10
[] (int, int y, int) -> int { return y; }(10,20,30); // returns 20
[] (int x) -> int { return x + 5; }(3); // returns (3 + 5)
[] (int x, int y) -> int { return x * y; }(7,10); // returns (7 * 10)