From ebdcc06e3964a49bfe13740b1bc8e6e74a6c17f7 Mon Sep 17 00:00:00 2001 From: Awin Huang Date: Mon, 13 Jun 2022 18:44:14 +0800 Subject: [PATCH] vault backup: 2022-06-13 18:44:14 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Affected files: 02. PARA/03. Resources(資源)/C++17/lambda.md --- 02. PARA/03. Resources(資源)/C++17/lambda.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/02. PARA/03. Resources(資源)/C++17/lambda.md b/02. PARA/03. Resources(資源)/C++17/lambda.md index 0d2fd72..c6c68bb 100644 --- a/02. PARA/03. Resources(資源)/C++17/lambda.md +++ b/02. PARA/03. Resources(資源)/C++17/lambda.md @@ -188,7 +188,7 @@ auto findInRange = [=, &numlist](int32_t start, int32_t end) { ... }; ``` -上面的例子中,`numlist` 會是一個參考擷取,其他的外部變數則是以值擷取。 +上面的例子中,`numlist` 會是參考擷取,其他的外部變數則是以值擷取。 或是: ```cpp @@ -196,4 +196,7 @@ auto findInRange = [&, numlist](int32_t start, int32_t end) { ... }; ``` -上面的例子中,`numlist` 會是一個以值擷取,其他的外部變數則是參考擷取。 \ No newline at end of file +上面的例子中,`numlist` 會以值擷取,其他的外部變數則是參考擷取。 + +但是,如果已經使用了 `=` ,就不可以再以值擷取其他變數,像是 `[=, numlist]` 就是不合法的。 +反之,如果已經使用了 `&`,就不可以再參考擷取其他變數,像是 `[&, &var1]` 就是不合法的。 \ No newline at end of file