Boost logo

Boost Users :

From: Joaquin M Lopez Munoz (joaquin_at_[hidden])
Date: 2007-08-06 03:16:03


LoadCom <LoadCom <at> sina.com> writes:

> Thanks that works.
>  
> Buy why that works?
>  
> Max
>
> On 8/5/07, "JOAQUIN LOPEZ MU?Z" <joaquin <at> tid.es>
> wrote:
> > Use an added level of brace enclosing:
> > {{
> > {"Chun", "Wang", 1441},
> > {"Chia", "Wang", 1443},
> > {"Ta", "Wang", 1445}
> > }};
[...]

boost::array<T,N> is an agregate class (which means
you can initialize it with a brace-enclosed list)
containing a member

  T elems[N];

which is in turn an aggregate. So, if you've got a
boost::array<People,3>, the list

  {
    {"Chun", "Wang", 1441},
    ...
  }

is apt to initialize elems, and for initializing the
boost::array you've got to add another level of {}:

  {{
    {"Chun", "Wang", 1441},
    ...
  }}

although the standard allows the omission of the outer
level under some circumnstances, as noted in

http://boost.org/doc/html/array/rationale.html

Hope it's clearer now. Best,

Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net