Question on boost array initializer
        Posted  
        
            by ArunSaha
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by ArunSaha
        
        
        
        Published on 2010-04-22T01:38:02Z
        Indexed on 
            2010/04/22
            1:43 UTC
        
        
        Read the original article
        Hit count: 378
        
I am trying to understand the boost array. The code can be read easily from author's site.
In the design rationale, author (Nicolai M. Josuttis) mentioned that the following two types of initialization is possible.
boost::array<int,4> a = { { 1, 2, 3 } };  // Line 1
boost::array<int,4> a = { 1, 2, 3 };      // Line 2
In my experiment with g++ (version 4.1.2) Line 1 is working but Line 2 is not. (Line 2 yields the following:
warning: missing braces around initializer for 'int [4]'
warning: missing initializer for member 'boost::array<int, 4ul>::elems'
)
Nevertheless, my main question is, how Line 1 is working? I tried to write a class similar to array.hpp and use statement like Line 1, but that did not work :-(. Can somebody explain me? Is there some boost specific thing happening in Line 1 that I need to be aware of?
Thanks in advance. Regards,
© Stack Overflow or respective owner