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.
}
Diese Codes werden nicht mit gcc 4.8.0 kompiliert. Ich rate nicht einmal den Typ decltype(x3)
. Was ist es? Und warum ist das Verhalten anders?Warum wird Auto anders abgeleitet?
Erklärung Fehler .... –
@GrijeshChauhan Sie spezifischer sein könnte? – Sungmin
'auto x {y}' ist eine 'std :: initializer_list'. – Xeo