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.
}
Kod ten nie jest kompilowany z gcc 4.8.0. Nawet nie odgaduję typu decltype(x3)
. Co to jest? I dlaczego zachowanie jest inne?Dlaczego auto jest wyprowadzane inaczej?
deklaracji .... –
@GrijeshChauhan można być bardziej konkretnego? – Sungmin
'auto x {y}' jest 'std :: initializer_list'. – Xeo