Boost logo

Boost Users :

Subject: Re: [Boost-users] [Boost.MultiArray]: size question
From: gast128 (gast128_at_[hidden])
Date: 2012-12-17 16:24:41


Larry Evans <cppljevans <at> suddenlink.net> writes:

>
> On 12/17/12 14:14, gast128 wrote:
> > This gives at least an assert:
> >
> > BOOST_ASSERT(size_type(idx - index_bases[0]) < extents[0]);
> >
> > Isn't there a better solution?
>
> Are you referring to multi_array for the array_dyn alternative
> mentioned in my OP? Or this this reply not intended for me?
>
> Could you provide the complete program that has this statement in it?
>
> I've grepped files here:
>
> http://svn.boost.org/svn/boost/sandbox/variadic_templates/sandbox/array_dyn
>
> for extents, and found none; hence, I'm confused :(

I am talking about multi_array, see title. Example code:

void f()
{
   typedef boost::multi_array<int, 2> Matrix;

   Matrix m1(boost::extents[2][3]);
   _ASSERT(m1.size() == 2);
   _ASSERT(m1[0].size() == 3);
   
   m1.resize(boost::extents[0][3]);
   _ASSERT(m1.size() == 0);
   //_ASSERT(m1[0].size() == 3); //<--assert
}


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net