1

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}

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

Sheed
  • 577
  • 4
  • 18
  • Some possible duplicate targets: [1](https://stackoverflow.com/questions/5666321/what-is-assignment-via-curly-braces-called-and-can-it-be-controlled) [2](https://stackoverflow.com/questions/1601201/c-struct-initialization-using-labels-it-works-but-how). – user202729 Jul 03 '18 at 08:59
  • (next time please only ask 1 question in a post. The other one is GCC's language extension, not standard C++) – user202729 Jul 03 '18 at 08:59
  • user202729, You mean the last examples? https://en.cppreference.com/w/cpp/language/aggregate_initialization This looks like standard c++ Also the stackoverflow link you've given doesn't use the words "brace-or-equals" – Sheed Jul 03 '18 at 09:00
  • 1
    *"(since C++20)"* – Bob__ Jul 03 '18 at 09:05
  • Well, indeed it is not yet official. I only put those with the intention of being exhaustive – Sheed Jul 03 '18 at 09:06

1 Answers1

7

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.

T.C.
  • 133,968
  • 17
  • 288
  • 421