Boost logo

Boost Users :

Subject: Re: [Boost-users] Boost.Array intialisation
From: alfC (alfredo.correa_at_[hidden])
Date: 2010-03-11 03:28:54


> That's fine, but how does one intialise a Boost.Array in member intialiser
> list, e.g.:

The only way I found to do this is

#include<boost/array.hpp>
struct Foo
{
   Foo()
    : m_a((boost::array<int, 4>){1,2,3,4})
   {
   }
   boost::array<int, 4> m_a;
};

I am using this kind of construction often now because it is the
cleanest and the most explicit that I can get but I don't know the
degree of portability or even correctness of such code.
For example I know that it works in GCC 4.1.2, GCC 4.4 and IntelCC 11
but it gives an error with gcc option -pedantic-errors (error: ISO C++
forbids compound-literals).

Despite of this possible issue I am using it anyway, but I also would
like to know what are the possible issues and portability (please, let
me know if you compiler is not gcc).

Alfredo


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