Boost logo

Boost :

From: Lie-Quan Lee (llee1_at_[hidden])
Date: 2001-04-09 14:43:24


At Mon, 9 Apr 2001 08:42:48 -0400,
Doug Gregor wrote:
>
> ------------------------------
> Interface summary:
>
> template<typename Result, typename Arg1, typename Arg2, ..., typename ArgN>
> class any_function
> {
> any_function();
> any_function(const any_function&);
> template<typename Functor> any_function(Functor);
> ~any_function();
>
> any_function& operator=(const int); // assignment to zero clears target
> template<typename Functor> any_function& operator=(Functor);
> any_function& operator=(const any_function&);
>
> void clear(); // clear out the target
>
> bool empty() const; // true if no target
> operator const void*() const; // evaluates true if non-empty
>
> Result operator()(Arg1, Arg2, ..., ArgN); // call target
> };
> -------------------------------
>
> Doug

Here are my two cents:

Could be there is speicalized versions of any_function class which
take a function pointer type template argument and deduce other types
from it ?

template <class Fp>
class any_function<function_traits<Fp>::return_type,
                   function_traits<Fp>::Arg1,
                   function_traits<Fp>::Arg2,
                   ...>
{
  any_function(Fp fp_);
  
  //...
}

Or maybe a set of functions:

template <class Fp>
function_traits<Fp>::return_type
eval_function(Fp fp);

template <class Fp>
function_traits<Fp>::return_type
eval_function(Fp fp, function_traits<Fp>::Arg1 arg1);

template <class Fp>
function_traits<Fp>::return_type
eval_function(Fp fp, function_traits<Fp>::Arg1 arg1, function_traits<Fp>::Arg2);

//more to take more arguments.

In fact, I am using the latter to create threads in my code.

--
Lie-Quan Lee

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