Boost logo

Boost :

From: Thorsten Ottosen (nesotto_at_[hidden])
Date: 2005-03-06 19:16:53

Hi Matthias,

"Matthias Kaeppler" <nospam_at_[hidden]> wrote in message
| Hello,
| because of the lack of a generic adaptor which indirects operations on
| pointers to the pointees, i.e. sorting a collection of pointers with
| predicates applying to the pointees, I have come up with two classes,
| indirecter_unary and indirecter_binary which do exactly that (thanks
| again to the people from boost users and comp.lang.c++ for assisting
| me). Both adaptors accept adaptable function objects as well as plain
| functions.

these classes are useful when we need to use a class; boost.bind won't
work since we don't know what type it returns.

I have been playing with similar functionality for Boost.Pointer Container
because the ptr_set class needs it.

I have a question, though. I'm thinking, what is the benefit of your approach
compared to

template< class Fun >
class indirect_fun
    Fun fun;
    typedef typename result_of<Fun>::type result;

    indirect_fun( Fun f ) : fun(f)
    { }

    template< class T >
    result operator( T* r ) const
   { return fun( *r ); }

    template< class T, class U >
    result operator( T* r, U* r2 ) const
   { return fun( *r, *r2 ); }

    // etc



Boost list run by bdawes at, gregod at, cpdaniel at, john at