mirror of
https://github.com/CnTransGroup/EffectiveModernCppChinese.git
synced 2025-02-13 21:00:31 +08:00
Update item2.md
This commit is contained in:
parent
6fa21f8143
commit
4753623c99
@ -160,10 +160,10 @@ auto createInitList()
|
|||||||
同样在C++14的lambda函数中这样使用auto也不能通过编译:
|
同样在C++14的lambda函数中这样使用auto也不能通过编译:
|
||||||
````cpp
|
````cpp
|
||||||
std::vector<int> v;
|
std::vector<int> v;
|
||||||
...
|
…
|
||||||
auto resetV =
|
auto resetV =
|
||||||
[&v](const auto& newValue){ v = newValue; }; //C++14
|
[&v](const auto& newValue){ v = newValue; }; //C++14
|
||||||
...
|
…
|
||||||
resetV({ 1, 2, 3 }); //错误!不能推导{ 1, 2, 3 }的类型
|
resetV({ 1, 2, 3 }); //错误!不能推导{ 1, 2, 3 }的类型
|
||||||
````
|
````
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user