我知道返回類型auto和decltype(auto)的含義。此外,我知道auto&&變量聲明。所以,我想auto&&的返回類型: template <class X, class Y>
auto a(X &&x, Y &&y) -> auto {
return x+y;
}
template <class X, class Y>
auto b(X &&x, Y &&y) ->
CPU:酷睿雙核 RAM: 4 GB OS: Windows 7的64位 IDE:代碼:: Blocks的16.0 編譯:TDM-GCC MinGW IT水平: Newb試圖學習C++。 我用下面的代碼來測試編譯: #include <iostream>
#include <string>
using namespace std;
auto add([](auto a, auto b){ r
考慮以下幾點: template<typename Der>
struct Base {
// NOTE: if I replace the decltype(...) below with auto, code compiles
decltype(&Der::operator()) getCallOperator() const {
return &Der::o
考慮下面的代碼: template< class T1 , class T2>
auto calc(T1 a , T2 b)
{
return a + b ;
}
template< class T1 , class T2>
auto calc(T1 a , T2 b) -> decltype(a + b)
{
return a + b ;
}
什麼在第二