Boost logo

Boost :

From: Dave Gomboc (dave_at_[hidden])
Date: 2003-08-08 17:15:19


> The problem is that boost::array is not a wrapper around an
> existing array, it IS an array. This implys making a superfluous
> copy of the array in some cases.
>
> Given an simple C array, I want a wrapper which will supply an
> iterator interface so that I can do something like.
>
> const in array{] = {1, 2, 3, 4};
> boost::array<int> ba(array);
> std::copy(ba.begin(), ba.end(), std_ostream_iterator<int>(std::cout));
>
> Is there already a way to do this? Or is there some reason why
> one would never want to do this?

AFAICR boost::array allows initialization. I would try

const boost::array<int> ba = {1, 2, 3, 4};
std::copy(ba.begin(), ba.end(), std_ostream_iterator<int>(std::cout));

Dave


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk