Boost.Array intialisation
Hello all,
the documentation describes that Boost.Array deliberately omits constructors
to allow intialisation in functions:
void F()
{
boost::array
Or use boost assign as shown inline below. Though I'm not sure of the performance differences. Roman Perepelitsa wrote:
2010/3/10 gast128
mailto:gast128@hotmail.com> That's fine, but how does one intialise a Boost.Array in member intialiser list
boost::array
MakeArray() { boost::array res = { 1, 2, 3, 4 }; return res; }
#include
struct Foo { Foo() : m_a(MakeArray()) {}
Foo() : m_a(list_of(1)(2)(3)(4)) {}
boost::array
m_a; }; Roman Perepelitsa.
Jeff
#include
#include using namespace boost::assign;
struct Foo { Foo() : m_a(list_of(1)(2)(3)(4)) {}
boost::array
m_a; }; Roman Perepelitsa.
Jeff
Thx this works. I was more hoping for a solution without a helper function (e.g. m_a({1, 2}), but that doesn't compile), but probably it doesn't exist. Got btw also a C4701 warning by uisng this construct. Haven't delved into it to see if it is a dangerous one.
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
alfC
#include
struct Foo { Foo() : m_a((boost::array ){1,2,3,4}) { } boost::array m_a; }; 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).
This doens't compile on vstudio 2003. I have to put here some extra dummy text, because without this text i get 'There's much more quoted text in your article than new. Prune quoted stuff.'.
participants (4)
-
alfC
-
gast128
-
Jeff Flinn
-
Roman Perepelitsa