Boost logo

Boost :

From: Shunsuke Sogame (mb2act_at_[hidden])
Date: 2006-07-20 06:30:45

Steven Burns wrote:
> Recently I came up with a modified version of boost::array that supports
> runtime sized arrays.
> The current boost::array implementation is great but every now and then
> you'll need runtime-sized arrays: it's simply impossible to know everything
> at
> compile time.
> It is backwards compatible:
> boost::array<int, 10> sarray;
> but it can be used this way now:
> boost::array<int> darray(10);
> I realize you could simply use std::vector, but sometimes all you want is a
> fixed-size array (but sized at runtime). Besides, I am not sure about the
> overhead involved with std::vector for these simple scenarios.
> Comments welcome,

Boost.Array looks deprecated by Boost.Range, IMHO.
(Broken compilers still need it, though.)
I'm not sure whether or not 'std::vector' made dynamic array deprecated.
Well, how's that? :-)

     template< class Value >
     struct array_range :
         private boost::base_from_member< boost::scoped_array<Value> >,
         boost::iterator_range<Value *>,
         private boost::noncopyable
         typedef boost::base_from_member< boost::scoped_array<Value> >
         typedef boost::iterator_range<Value *> super_t;

         explicit array_range(std::size_t sz) :
             scoped_array_bt(new Value[sz]),
scoped_array_bt::member.get() + sz)
         { }

Shunsuke Sogame

Boost list run by bdawes at, gregod at, cpdaniel at, john at