Boost.MultiArray bounds checking

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Boost.MultiArray bounds checking

Frank Mori Hess

I'm using boost 1.32, and boost::multi_array doesn't seem to provide any
bounds-checked access.  I'm curious if there are any plans to add a
bounds-checked at() member function to complement the [] operator?  Or, is
there some reason it is impractical?

--
Frank

_______________________________________________
Boost-users mailing list
[hidden email]
http://lists.boost.org/mailman/listinfo.cgi/boost-users

attachment0 (196 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Boost.MultiArray bounds checking

Ronald Garcia
Hi Frank,

There are no plans to add an at() member function.  However, I have
considered adding bounds checking to MultiArray operator[] as a debug
mode option.

ron



On Feb 2, 2006, at 9:58 AM, Frank Hess wrote:

>
> I'm using boost 1.32, and boost::multi_array doesn't seem to provide
> any
> bounds-checked access.  I'm curious if there are any plans to add a
> bounds-checked at() member function to complement the [] operator?  
> Or, is
> there some reason it is impractical?
>
> --
> Frank
> _______________________________________________
> Boost-users mailing list
> [hidden email]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users

_______________________________________________
Boost-users mailing list
[hidden email]
http://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: Boost.MultiArray bounds checking

Thorsten Ottosen
Ronald Garcia wrote:
> Hi Frank,
>
> There are no plans to add an at() member function.  However, I have
> considered adding bounds checking to MultiArray operator[] as a debug
> mode option.

What consideration are you making? Some lone time ago I added that
boost::array. Can it hurt to add it?

-Thorsten

_______________________________________________
Boost-users mailing list
[hidden email]
http://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: Boost.MultiArray bounds checking

Sohail Somani
In reply to this post by Frank Mori Hess
> Ronald Garcia wrote:
> > Hi Frank,
> >
> > There are no plans to add an at() member function.  However, I have
> > considered adding bounds checking to MultiArray operator[]
> as a debug
> > mode option.
>
> What consideration are you making? Some lone time ago I added that
> boost::array. Can it hurt to add it?

As a user of multi array, I would like to have bounds checking for [] if
NDEBUG is not defined (or something similar). It helps a lot while
debugging. An assertion would be best.

Sohail

_______________________________________________
Boost-users mailing list
[hidden email]
http://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: Boost.MultiArray bounds checking

Ronald Garcia
In reply to this post by Thorsten Ottosen
Hi Thorsten,

Honestly, I was just considering whether it would be worth while to
take the time to do so.  Given the amount of interest shown here, I
have gone ahead and added range checking to the value accessor
operator[]() and the element accessor operator()().  The range checks
are based on boost/assert.hpp: they can be disabled by either defining
BOOST_DISABLE_ASSERTS or NDEBUG.

I have yet to update the documentation to reflect this, but I thought
it wise to announce the feature addition.

Cheers,
ron

On Feb 2, 2006, at 2:15 PM, Thorsten Ottosen wrote:

> Ronald Garcia wrote:
>> There are no plans to add an at() member function.  However, I have
>> considered adding bounds checking to MultiArray operator[] as a debug
>> mode option.
>
> What consideration are you making? Some lone time ago I added that
> boost::array. Can it hurt to add it?

_______________________________________________
Boost-users mailing list
[hidden email]
http://lists.boost.org/mailman/listinfo.cgi/boost-users