Boost logo

Boost :

From: Dave Gomboc (dave_at_[hidden])
Date: 2003-08-09 03:54:29


dave> > const in array{] = {1, 2, 3, 4};
dave> > boost::array<int> ba(array);
dave> > std::copy(ba.begin(), ba.end(), std_ostream_iterator<int>(std::cout));
dave> >
dave> > Is there already a way to do this? Or is there some reason why
dave> > one would never want to do this?
dave>
dave> AFAICR boost::array allows initialization. I would try
dave>
dave> const boost::array<int> ba = {1, 2, 3, 4};
dave> std::copy(ba.begin(), ba.end(), std_ostream_iterator<int>(std::cout));
>
> But he doesn't want coping. There's the simple solution
>
> const int array[] = {1, 2, 3, 4};
> std::copy(array, array + 4, ...);
>
> and also there's the array_traits in the sandbox.
>
> However, did he want the exact interface as boost::array? If so, I'd say
> we need a new class called ptr_array that adapts a pointer and a size
> into an array.

Is this a copy, or an initialization?

> const in array{] = {1, 2, 3, 4};

Is this a copy, or an initialization?

> const boost::array<int> ba = {1, 2, 3, 4};

Dave


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