Dela via


Kompilatorfel C2076

En klammerparentessluten initialiserarlista kan inte användas i ett nytt uttryck vars typ innehåller "auto/decltype(auto)"

Anmärkningar

Om en auto typspecificerare visas i specificerarsekvensen för en ny typidentifierare eller typidentifierare för ett new uttryck måste uttrycket innehålla en initialiserare av formuläret ( assignment-expression ). Kompilatorn härleder typidentifieraren från assignment-expression initiatorn. Ett exempel:

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*

Lös problemet genom att använda parenteser för att omsluta initieringsvärdet för new uttrycket.