¿Es posible inicializar una matriz de no POD con operador nuevo y sintaxis de inicializador?
Acabo de leer y entender¿Es posible inicializar una matriz en C ++ 11 utilizando un nuevo operador?, pero no resuelve mi problema.
Este código me da un error de compilación en Clang:
struct A
{
A(int first, int second) {}
};
void myFunc()
{
new A[1] {{1, 2}};
}
Esperaba que {{1, 2}} inicializara la matriz con un único elemento, a su vez inicializado con el constructor args {1, 2}, pero obtengo este error:
error: no matching constructor for initialization of 'A'
new A[1] {{1, 2}};
^
note: candidate constructor not viable: requires 2 arguments, but 0 were provided
A(int first, int second) {}
^
note: candidate constructor (the implicit copy constructor) not viable: requires 1 argument, but 0 were provided
struct A
^
¿Por qué esta sintaxis no funciona?