Hello all,
I have this functor structure :
I saw that I could do this with the boost library:
But I cannot use boost in my current project. So I need to re-code this boost::function.
I really don't know how to hide the Wrapper type to the end-user, as boost::function does.
As to me, if there is a functor structure, we have to copy this structure in data member of the Function class. But if we copy this structure, we will have to explicit its type in the constructor of Function.
Please help, I feel so doomed !!
I have this functor structure :
Code:
template< typename T >
struct Equal
{
explicit Equal( T e ) : e_( e ) {}
template< typename T2 >
bool operator()( T2 rhs ) const
{
return e_ == rhs;
}
T e_;
};
I saw that I could do this with the boost library:
Code:
boost::function< bool( int ) > fun;
Equal< int > e( 42 );
fun = e;
But I cannot use boost in my current project. So I need to re-code this boost::function.
Code:
template< typename Type >
struct Function
{
template< typename Wrapper >
explicit Function( Wrapper w ) : f_( w ) {}
bool operator()( Type e )
{
return f_( e );
}
??? f_;
}
I really don't know how to hide the Wrapper type to the end-user, as boost::function does.
As to me, if there is a functor structure, we have to copy this structure in data member of the Function class. But if we copy this structure, we will have to explicit its type in the constructor of Function.
Please help, I feel so doomed !!