Boost logo

Boost :

From: Gary Powell (Gary.Powell_at_[hidden])
Date: 2000-10-17 18:48:26


> I've been trying to work out a general method for using STL-style
> algorithms
> on containers of pointers. I have a solution that actually compiles and
> works on GCC and VC6sp4, but I'm not too fond of the syntax (or the
> formatting!):
If you don't need VC6sp4 compatibility, the VTL library
has a container adaptor which promotes pointers to
references.

typedef vector<int *> vecPtr;
   vecPtr v();

boost::polymorphic_view<vecPtr, mutable_view_tag> pv;

  sort(pv.begin(), pv.end()); // will sort the contents.

Or the Lambda library has an operator*() as part of it.

  sort(v.begin(), v.end(), *free1 > *free2 ); // will sort the pointers.

Either of these solutions are a lot easier on the eyes.

  Yours,
 -gary-

gary.powell_at_[hidden]


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