Boost logo

Boost :

From: Douglas Gregor (gregod_at_[hidden])
Date: 2002-07-19 13:44:54


On Friday 19 July 2002 11:31 am, Douglas Gregor wrote:
> function<void (char const * name, int mode)> pf;

I've implemented this capability in Boost.Function; it's in CVS now. The class
template boost::function now effectively has a dual signature:

The old signature:
  template<typename R,
           typename T1,
           typename T2,
           ...
           typename TN>
  class function;

The new signature:
  template<typename Signature, // a function type
           typename Policy = empty_function_policy,
           typename Mixin = empty_function_mixin,
           typename Allocator = std::allocator<void> >
  class function;

The two signatures are essentially interchangeable. The former signature will
be considered deprecated and will produce a compile-time warning (thanks to
Fernando for the code; it'll be integrated in a near future), and will be
removed in the future to shorten the function class template signature.

As implemented, the code only works for compilers with support for partial
specialization and has only been tested with GCC 3.1 thus far. I'll add more
workarounds in the future.

At the moment, I believe that the best option is to leave all of the functionN
classes as they are, so the syntax of function0, function1, etc. will not
change even when the old syntax is not allowed for the 'function' class
template. Future revisions may deprecate and remove the functionN classes
entirely, depending on platform-specific issues with the new syntax (e.g.,
the __cdecl ugliness).

Comments always welcome.

        Doug


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