Boost logo

Boost :

From: Jonathan Turkanis (technews_at_[hidden])
Date: 2004-03-02 02:00:23


"Roland Richter" <roland_at_[hidden]> wrote in message
news:40432D65.2080806_at_flll.jku.at...
> Boosters,
>
> I want to write a function which compares two shared_array's
> element-wise (operator==() compares for pointer equality).
>
> How to get the number of elements a given shared_array contains?
> At first glance there seems to be no possibility; am I missing
> something?

shared_array helps you manage the lifetime of a dynamically allocated
array. With shared_array, just as with raw dynamically allocated
arrays, you must keep track of the size yourself. If you look at the
shared_array constructors, you'll see there's no way for it to know
the array's size.

You can always use a shared_ptr to a vector if you need to be able to
query the size.

Jonathan


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