From 352834243af82ce0bd56be449ce5b5c6f2f28b07 Mon Sep 17 00:00:00 2001 From: Awin Huang Date: Mon, 13 Jun 2022 15:30:30 +0800 Subject: [PATCH] vault backup: 2022-06-13 15:30:30 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 | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/02. PARA/03. Resources(資源)/C++17/lambda.md b/02. PARA/03. Resources(資源)/C++17/lambda.md index ffae872..6598a50 100644 --- a/02. PARA/03. Resources(資源)/C++17/lambda.md +++ b/02. PARA/03. Resources(資源)/C++17/lambda.md @@ -23,4 +23,14 @@ description: auto comapre = [] (int x, int y) -> bool { return x < y; }; -``` \ No newline at end of file +``` + +## Lamdba的擷取子句 +以中括號開頭的 *lamdba 導入器*可以將外部的變數傳給 Lamdba 運算式,正式名稱是「擷取子句(capture clause)」。 +[=] 表示它們會以值擷取(captured by value)。 +[&] 表示它們會以址擷取(captured by reference)。 + +### 以值擷取(captured by value) +假設有一個function如下: + +### 以址擷取(captured by reference) \ No newline at end of file