vault backup: 2022-07-13 10:53:13
Affected files: .obsidian/workspace 02. PARA/03. Resources(資源)/C++17/for_each.md
This commit is contained in:
8
.obsidian/workspace
vendored
8
.obsidian/workspace
vendored
@@ -9,7 +9,7 @@
|
|||||||
"state": {
|
"state": {
|
||||||
"type": "markdown",
|
"type": "markdown",
|
||||||
"state": {
|
"state": {
|
||||||
"file": "02. PARA/01. Project(專案)/008. Sentinel.md",
|
"file": "02. PARA/03. Resources(資源)/C++17/for_each.md",
|
||||||
"mode": "source",
|
"mode": "source",
|
||||||
"source": true
|
"source": true
|
||||||
}
|
}
|
||||||
@@ -69,7 +69,7 @@
|
|||||||
"state": {
|
"state": {
|
||||||
"type": "backlink",
|
"type": "backlink",
|
||||||
"state": {
|
"state": {
|
||||||
"file": "02. PARA/01. Project(專案)/008. Sentinel.md",
|
"file": "02. PARA/03. Resources(資源)/C++17/for_each.md",
|
||||||
"collapseAll": false,
|
"collapseAll": false,
|
||||||
"extraContext": false,
|
"extraContext": false,
|
||||||
"sortOrder": "alphabetical",
|
"sortOrder": "alphabetical",
|
||||||
@@ -86,7 +86,7 @@
|
|||||||
"state": {
|
"state": {
|
||||||
"type": "outline",
|
"type": "outline",
|
||||||
"state": {
|
"state": {
|
||||||
"file": "02. PARA/01. Project(專案)/008. Sentinel.md"
|
"file": "02. PARA/03. Resources(資源)/C++17/for_each.md"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -116,11 +116,11 @@
|
|||||||
},
|
},
|
||||||
"active": "ec13ce58b15fa6d4",
|
"active": "ec13ce58b15fa6d4",
|
||||||
"lastOpenFiles": [
|
"lastOpenFiles": [
|
||||||
|
"02. PARA/01. Project(專案)/008. Sentinel.md",
|
||||||
"02. PARA/03. Resources(資源)/C++17/for_each.md",
|
"02. PARA/03. Resources(資源)/C++17/for_each.md",
|
||||||
"02. PARA/03. Resources(資源)/讀書筆記/20220619 - 精確的力量.md",
|
"02. PARA/03. Resources(資源)/讀書筆記/20220619 - 精確的力量.md",
|
||||||
"02. PARA/03. Resources(資源)/C++17/智慧指標.md",
|
"02. PARA/03. Resources(資源)/C++17/智慧指標.md",
|
||||||
"02. PARA/03. Resources(資源)/C++17/C++17.md",
|
"02. PARA/03. Resources(資源)/C++17/C++17.md",
|
||||||
"02. PARA/01. Project(專案)/008. Sentinel.md",
|
|
||||||
"00. TOP/01. TODO.md",
|
"00. TOP/01. TODO.md",
|
||||||
"02. PARA/02. Area(領域)/20150803 - Android/ADB 取得 APK 的 icon.md",
|
"02. PARA/02. Area(領域)/20150803 - Android/ADB 取得 APK 的 icon.md",
|
||||||
"02. PARA/02. Area(領域)/20150803 - Android/ADB.md",
|
"02. PARA/02. Area(領域)/20150803 - Android/ADB.md",
|
||||||
|
|||||||
@@ -8,4 +8,17 @@ template<class InputIterator, class Function>
|
|||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
它需要3個參數,第1個是開始的iterator,第2是結束的 iterator,第3個是要用來處理的 function
|
它需要3個參數,第1個是開始的iterator,第2是結束的 iterator,第3個是要用來處理的 function。
|
||||||
|
|
||||||
|
一個簡單的例子,有一個array,需要把每一個數都加1:
|
||||||
|
```cpp
|
||||||
|
vector<int> arr1 = { 4, 5, 8, 3, 1 };
|
||||||
|
|
||||||
|
for_each(
|
||||||
|
arr1.begin(), // _Start
|
||||||
|
arr1.end(), // _Last
|
||||||
|
[](int& val) { // _Func
|
||||||
|
val += 1;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
```
|
||||||
Reference in New Issue
Block a user