M
Matthias
Hi,
again, I have a problem using containers of pointers (I'm near to the
point to drop them alltogether and work on usual containers instead...).
The problem is, if I want to perform some action on an element in a
normal container (normal means everyhing-but-a-pointer), I can do
something like this:
for_each( coll.begin(), coll.end(), do_something );
Same for sorting:
partition( coll.begin(), coll.end(), Predicate() );
Now, what if coll is a collection of pointers? The predicate will give
strange results, because it looks only at addresses.
So, instead of rewriting the predicate to work with pointers, is there
some kind of dereferencing adaptor already available, which allows me to
do this:
partition( coll.begin(), coll.end(), Dereference( Predicate() ) );
or something similar?
again, I have a problem using containers of pointers (I'm near to the
point to drop them alltogether and work on usual containers instead...).
The problem is, if I want to perform some action on an element in a
normal container (normal means everyhing-but-a-pointer), I can do
something like this:
for_each( coll.begin(), coll.end(), do_something );
Same for sorting:
partition( coll.begin(), coll.end(), Predicate() );
Now, what if coll is a collection of pointers? The predicate will give
strange results, because it looks only at addresses.
So, instead of rewriting the predicate to work with pointers, is there
some kind of dereferencing adaptor already available, which allows me to
do this:
partition( coll.begin(), coll.end(), Dereference( Predicate() ) );
or something similar?