
Michael McNeil Forbes wrote:
What is the recommended way of initializing an array from a concatenation of other arrays?
list_of::range looks right and I would like to use something like:
array
a = { 1, 2 }; array b = { 3, 4 }; array c = list_of<int>().range(a).range(b); However, list_of<int>() inserts a default value (so that list_of<int>().range(a).range(b) == {0,1,2,3,4}). There are several workarounds, e.g.
array
c = list_of<int>(a[0]) .range(a.begin()+1, a.end()) .range(b); array c = boost::assign_detail::generic_list<int>() .range(a) .range(b); The first is ugly; the second seems an abuse of assign_detail (and fails for static_generic_list).
I am sure I am missing a simple solution, but can't seem to find it.
Thanks, Michael.
The proposed extension of Boost.Assign offers an alternative approach to
this problem:
boost::array