編譯程序錯誤 C2076
以大括弧括住的初始化表達式清單不能用於類型包含 'auto/decltype(auto)' 的新運算式中
auto
如果型別規範出現在新型別標識符的規範序列或表達式的new
型別標識碼中,則表達式必須包含格式( assignment-expression )
的初始化表達式。 編譯程式會從 assignment-expression
初始化表達式中的 推斷型別標識符。 例如,
new auto(42); // new allocates int
auto c = new auto('a'); // c is of type char*, new allocates char
new (auto*)(static_cast<short*>(nullptr)); // allocates type short*
若要解決此問題,請使用括弧括住表達式的 new
初始化值。