mirror of
https://github.com/AnthonyCalandra/modern-cpp-features.git
synced 2025-12-18 10:34:35 +03:00
Merge pull request #14 from mos6502/master
Fix example for decltype(auto) and Initializer lists
This commit is contained in:
@@ -476,7 +476,7 @@ auto x1 = x; // int
|
|||||||
decltype(auto) x2 = x; // const int
|
decltype(auto) x2 = x; // const int
|
||||||
int y = 0;
|
int y = 0;
|
||||||
int& y1 = y;
|
int& y1 = y;
|
||||||
auto y2 = y; // int
|
auto y2 = y1; // int
|
||||||
decltype(auto) y3 = y1; // int&
|
decltype(auto) y3 = y1; // int&
|
||||||
int&& z = 0;
|
int&& z = 0;
|
||||||
auto z1 = std::move(z); // int
|
auto z1 = std::move(z); // int
|
||||||
@@ -594,9 +594,9 @@ int sum(const std::initializer_list<int>& list) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto list = { 1, 2, 3 };
|
auto list = { 1, 2, 3 };
|
||||||
f(list); // == 6
|
sum(list); // == 6
|
||||||
f({ 1, 2, 3 }); // == 6
|
sum({ 1, 2, 3 }); // == 6
|
||||||
f({}); // == 0
|
sum({}); // == 0
|
||||||
```
|
```
|
||||||
|
|
||||||
### Static assertions
|
### Static assertions
|
||||||
|
|||||||
Reference in New Issue
Block a user