mirror of
https://github.com/CnTransGroup/EffectiveModernCppChinese.git
synced 2025-02-05 16:51:05 +08:00
将 C++11 版本中的 decltype(auto) 改为 auto
This commit is contained in:
parent
dd5687afb8
commit
bba456f12f
@ -125,7 +125,7 @@ authAndAccess(Container&& c,Index i){
|
|||||||
这样就能对我们的期望交上一份满意的答卷,但是这要求编译器支持C++14。如果你没有这样的编译器,你还需要使用C++11版本的模板,它看起来和C++14版本的极为相似,除了你不得不指定函数返回类型之外:
|
这样就能对我们的期望交上一份满意的答卷,但是这要求编译器支持C++14。如果你没有这样的编译器,你还需要使用C++11版本的模板,它看起来和C++14版本的极为相似,除了你不得不指定函数返回类型之外:
|
||||||
````cpp
|
````cpp
|
||||||
template<typename Container,typename Index> //最终的C++11版本
|
template<typename Container,typename Index> //最终的C++11版本
|
||||||
decltype(auto)
|
auto
|
||||||
authAndAccess(Container&& c,Index i)
|
authAndAccess(Container&& c,Index i)
|
||||||
->decltype(std::forward<Container>(c)[i])
|
->decltype(std::forward<Container>(c)[i])
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user