Skip to content

Commit 6187049

Browse files
committed
F.21 updated C++17 example
1 parent 7c9ec43 commit 6187049

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

CppCoreGuidelines.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2570,8 +2570,7 @@ With C++11 we can write this, putting the results directly in existing local var
25702570

25712571
With C++17 we may be able to write something like this, also declaring the variables:
25722572

2573-
auto { iter, success } = myset.insert("Hello");
2574-
if (success) do_something_with(iter);
2573+
if (auto [ iter, success ] = myset.insert("Hello"); success) do_something_with(iter);
25752574

25762575
**Exception**: For types like `string` and `vector` that carry additional capacity, it can sometimes be useful to treat it as in/out instead by using the "caller-allocated out" pattern,
25772576
which is to pass an output-only object by reference to non-`const` so that when the callee writes to it the object can reuse any capacity or other resources that it already contains.

0 commit comments

Comments
 (0)