C++ features by examples
Lambda capture this by value
Collaboration diagram for Lambda capture this by value:

Functions

void capture_this_by_value ()
 
void lambda_17 ()
 

Detailed Description

constexpr_lambda

Lambda capture

Function Documentation

◆ capture_this_by_value()

void capture_this_by_value ( )

Definition at line 187 of file 17.cpp.

188{
189 struct capture_value_o {
190 int value {1};
191 auto get_value_copy() {
192 return [*this] { return value; };
193 }
194 };
195
196 capture_value_o mo;
197 auto val = mo.get_value_copy();
198 mo.value = 2;
199 assert(val() == 1);
200}
Here is the caller graph for this function:

◆ lambda_17()

void lambda_17 ( )

Definition at line 202 of file 17.cpp.

203{
204 assert(can_be_constexpr1(2) == 2);
205 int i = 3;
206 assert(can_be_constexpr2(can_be_constexpr1, 3) == 3);
207 non_const(1);
209}
auto can_be_constexpr2
Definition: 17.cpp:156
auto non_const
Definition: 17.cpp:164
auto can_be_constexpr1
Definition: 17.cpp:155
void capture_this_by_value()
Definition: 17.cpp:187
Here is the call graph for this function:
Here is the caller graph for this function: