Does the equal sign make a difference in brace initialization? eg. ‘T a = {}’ vs ‘T a{}’

The only significant difference I know is in the treatment of explicit constructors:

struct foo
{
    explicit foo(int);
};

foo f0 {42};    // OK
foo f1 = {42};  // not allowed

This is similar to the “traditional” initialization:

foo f0 (42);  // OK
foo f1 = 42;  // not allowed

See [over.match.list]/1.


Apart from that, there’s a defect (see CWG 1270) in C++11 that allows brace-elision only for the form T a = {something}

struct aggr
{
    int arr[5];
};

aggr a0 = {1,2,3,4,5};  // OK
aggr a1 {1,2,3,4,5};    // not allowed

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)