int main(){
int x{};
auto x2 = x;
auto x3{x};
static_assert(is_same<int, decltype(x)>::value, "decltype(x) is the same as int");
static_assert(is_same<int, decltype(x2)>::value, "decltype(x2) is the same as int");
static_assert(is_same<int, decltype(x3)>::value, "decltype(x3) is the same as int"); // Error here.
}
此代码无法使用 gcc 4.8.0 编译。我什至不猜测decltype(x3)
. 它是什么?为什么行为不同?