Boost logo

Boost :

From: Thorsten Ottosen (nesotto_at_[hidden])
Date: 2003-06-12 02:26:22


Hi Alex,

> There are many more possibilities beyond those described here. Does this
> sound interesting to anyone????

I don't have time to comment very thoroughly, but I can say that it does
sound
interesting. In the project I'm working on now I needed to sort the pointers
from
several containers which was not that hard.

> // widgets_ and widget_ptrs_ get populated with some values
> . . .
> for (unsigned int i = 0; i < widgets_.size(); ++i)
> {
> widget_ptrs_.push_back(&widgets_[i]);
> }

You can avoid your handcoded loop by something like

transform( ..., &address_of );

of course you would have to resize the destination vector, but wouldn't you
do that
anyway to save some allocations?

What would have been nice was some kind of template that could generate
oprator<, operator= etc
if there was a non-pointerversion of the class.

regards

Thorsten


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