C++ features by examples
Functions
lambda Namespace Reference
C++ examples by version
»
C++20 examples
»
Language
Functions
void
lambda_20
()
Function Documentation
◆
lambda_20()
void lambda::lambda_20
(
)
Definition at line
115
of file
20.cpp
.
116
{
117
#if __cplusplus >= 201709
118
// generic lambda, operator() is a template with two parameters
119
auto
glambda = []<
class
T>(T a, auto&& b) {
return
a < b; };
120
assert(glambda(1,2));
121
// generic lambda, operator() is a template with one parameter pack
122
auto
f = []<
typename
...Ts>(Ts&& ...ts) {
123
return
1;
124
};
125
assert(f(1,2,3));
126
127
struct
point {
int
x, y; };
128
auto
point_lambda = []<
class
T=point>(T&& var) {};
129
point_lambda({1, 2});
130
131
#if __cpp_template_template_args && __GNUG__ > 8
132
assert(make_lambda_with_parameter_pack_capture(1,2,3)() == 6);
133
#endif
134
#endif
135
}
Here is the caller graph for this function:
lambda
Generated by
1.9.3