-
13 votesanswersviews
如何声明一个推导出其返回类型的函数?
考虑这个 C++1y 代码(LIVE EXAMPLE): #include <iostream> auto foo(); int main() { std::cout << foo(); // ERROR! } auto foo() { return 1234; } 编译器(GCC 4.8.1)慷慨地发现了这个错误: main.cpp:在函数'... -
2 votesanswersviews
为什么在Visual C 2015 update 3中没有使用constexpr自动返回类型推导?
此代码在GCC 4.9和Clang 3.5(带有标志-std = c 14)中编译并运行良好,但在VC 2015中给出了编译错误 . 请注意 operator* 中的自动返回类型: #include <cstdio> struct A { int i; constexpr A() : i(0) {}; constexpr A(int i) : i(i) {};... -
216 votesanswersviews
可以使用C 11 's ' auto'提高性能吗?
我可以看出为什么C11中的 auto 类型提高了正确性和可维护性 . 我读过它也可以提高性能(Herb Sutter的Almost Always Auto),但我错过了一个很好的解释 . auto 如何提高绩效? 谁能举个例子?