Boost logo

Boost :

From: Martin Bonner (martin.bonner_at_[hidden])
Date: 2005-10-04 09:55:08


----Original Message----
From: Boris [mailto:boris_at_[hidden]]
Sent: 04 October 2005 13:18
To: boost_at_[hidden]
Subject: Re: [boost] boost::dynamic_array

> The reason why I don't want to use std::vector in the project I work
> on is that I need a two-dimensional array. Two-dimensional means that
> the array stores not only the length but also width and height.
> Additionally its elements can be accessed with operator()(size_t
> column, size_t row). Now I could derive my two-dimensional array from
> std::vector but that doesn't make much sense because how should the
> dimensions change when someone calls push_back()? A fixed-size array
> whose size can be set a runtime would be an ideal candidate to derive
> my two-dimensional array from. For all arrays with more than one
> dimension std::vector isn't probably an ideal parent class.

So don't /derive/ from std::vector, /contain/ a std::vector instead (and
forward the appropriate calls to it).

It's really not very difficult (particularly as you don't need to both with
eg any of the 'insert' overloads).

-- 
Martin Bonner
Martin.Bonner_at_[hidden]
Pi Technology, Milton Hall, Ely Road, Milton, Cambridge, CB4 6WZ,
ENGLAND Tel: +44 (0)1223 441434

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