Jump to content

  • Log In with Google      Sign In   
  • Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at $59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.


Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!


#ActualAndy Gainey

Posted 28 July 2014 - 10:31 AM

Why exactly can't you brace-initialize this array? That isn't a C++11 only thing.

 

...

 

Therefore, 8.5.1/2, which states that aggregates can be brace-initialized is applicable.

 

bool array[2] = {}; should compile just fine (and it does indeed compile fine using GCC with either --std=c++03 or --std=c++98).

 

 

Not exactly relevant, but also note that array[0]=array[1]=false; most probably doesn't initialize the array in the order you expect.

 

Were you declaring that as a member variable, or just a local variable?  From what I understand, non-static inline member initialization is also a C++11 thing.  Without that feature, the member variable needs to either be initialized in the constructor's initializer list, or within the constructor body, neither of which would support the syntax provided in your post.

 

Edit:  Ninja-ed by SiCrane!


#1Andy Gainey

Posted 28 July 2014 - 10:30 AM

Why exactly can't you brace-initialize this array? That isn't a C++11 only thing.

 

...

 

Therefore, 8.5.1/2, which states that aggregates can be brace-initialized is applicable.

 

bool array[2] = {}; should compile just fine (and it does indeed compile fine using GCC with either --std=c++03 or --std=c++98).

 

 

Not exactly relevant, but also note that array[0]=array[1]=false; most probably doesn't initialize the array in the order you expect.

 

Were you declaring that as a member variable, or just a local variable?  From what I understand, non-static inline member initialization is also a C++11 thing.  Without that feature, the member variable needs to either be initialized in the constructor's initializer list, or within the constructor body, neither of which would support the syntax provided in your post.


PARTNERS