Jump to content

  • Log In with Google      Sign In   
  • Create Account

#Actualsamoth

Posted 28 July 2014 - 09:50 AM

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

 

C++03 8.5.1/1 [dcl.init.aggr] states:

 

An aggregate is an array or a class (clause 9) with no user-declared constructors (12.1), no private or protected
non-static data members (clause 11), no base classes (clause 10), and no virtual functions (10.3).

All of that is certainly true for an array of bool with size 2.

 

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.


#1samoth

Posted 28 July 2014 - 09:48 AM

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

 

C++03 8.5.1/1 [dcl.init.aggr] states:

 

An aggregate is an array or a class (clause 9) with no user-declared constructors (12.1), no private or protected
non-static data members (clause 11), no base classes (clause 10), and no virtual functions (10.3).

All of that is certainly true for an array of bool with size 2.

 

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)


PARTNERS