mardi 12 janvier 2021

Why does defining an empty copy ctor beside a deleted default ctor make a value initialization with empty list fail?

In short, why the code below behaves like described in the comments?

struct A
{
    A() = delete;
    //A(const A&) {} // uncommenting this...
};

int main()
{
    A a{}; // ... breaks this
    //A(); // this fails in either case because of `A() = delete;` only
}

What part of the standard (or at least a page on cppreference) should I look at to understand this?

Aucun commentaire:

Enregistrer un commentaire