mirror of
https://github.com/changkun/modern-cpp-tutorial.git
synced 2025-12-16 20:27:08 +03:00
@@ -105,6 +105,8 @@ The type of the captured variable being declared is judged according to the expr
|
||||
and the judgment is the same as using `auto`:
|
||||
|
||||
```cpp
|
||||
#include <memory>
|
||||
|
||||
void lambda_expression_capture() {
|
||||
auto important = std::make_unique<int>(1);
|
||||
auto add = [v1 = 1, v2 = std::move(important)](int x, int y) -> int {
|
||||
|
||||
@@ -90,7 +90,8 @@ C++14 给与了我们方便,允许捕获的成员用任意的表达式进行
|
||||
|
||||
```cpp
|
||||
#include <iostream>
|
||||
#include <utility>
|
||||
#include <memory> // std::make_unique
|
||||
#include <utility> // std::move
|
||||
|
||||
int main() {
|
||||
auto important = std::make_unique<int>(1);
|
||||
|
||||
@@ -9,7 +9,8 @@
|
||||
|
||||
|
||||
#include <iostream>
|
||||
#include <utility>
|
||||
#include <memory> // std::make_unique
|
||||
#include <utility> // std::move
|
||||
|
||||
void lambda_value_capture() {
|
||||
int value = 1;
|
||||
|
||||
Reference in New Issue
Block a user