Sheed
Sheed

Reputation: 619

what is a brace-or-equals initializer?

I know this question is simple, but it is so simple I have found no resources defining me what is a "brace-or-equals".

Are those all brace-or-equals initializer?

++++++++++++++++++++++++++++++++++++++

int foo= 42;

int foo{42};

int foo= {42};

int foo[]{41,42,43};

int foo[]={41,42,43};

struct Foo{
    int data= 42;
};

Considering the aformentioned structure, with data initialized or not, in both cases:

Foo foo{42}
Foo foo= {42}
Foo foo{.data=42}
Foo foo= {.data=42}

++++++++++++++++++++++++++++++++++++++

Upvotes: 1

Views: 2549

Answers (1)

T.C.
T.C.

Reputation: 137301

It's literally what it says on the tin: an initializer of the form = something ("equals") or { something } ("brace"). In other words, it excludes the ( something ) form of initializers.

The name comes from the grammar nonterminal for the construct.

Upvotes: 7

Related Questions