mirror of
https://github.com/CnTransGroup/EffectiveModernCppChinese.git
synced 2026-08-22 14:23:28 +08:00
Update item4.md
This commit is contained in:
@@ -70,7 +70,7 @@ const auto vw = createVec(); //使用工厂函数返回值初始化vw
|
||||
|
||||
if (!vw.empty()){
|
||||
f(&vw[0]); //调用f
|
||||
...
|
||||
…
|
||||
}
|
||||
````
|
||||
在这段代码中包含了一个用户定义的类型`Widget`,一个STL容器`std::vector`和一个`auto`变量`vw`,这个更现实的情况是你可能在会遇到的并且想获得他们类型推导的结果,比如模板类型形参`T`,比如函数`f`形参`param`。
|
||||
@@ -146,7 +146,7 @@ std::vetor<Widget> createVec(); //工厂函数
|
||||
const auto vw = createVec(); //使用工厂函数返回值初始化vw
|
||||
if (!vw.empty()){
|
||||
f(&vw[0]); //调用f
|
||||
...
|
||||
…
|
||||
}
|
||||
````
|
||||
在GNU和Clang的编译器环境下,使用Boost.TypeIndex版本的`f`最后会产生下面的(准确的)输出:
|
||||
|
||||
Reference in New Issue
Block a user