Boost logo

Boost :

From: Giovanni Piero Deretta (gpderetta_at_[hidden])
Date: 2007-12-05 05:42:18

On Dec 5, 2007 11:27 AM, Giovanni Piero Deretta <gpderetta_at_[hidden]> wrote:
> On Dec 3, 2007 10:57 AM, John Torjo <john.groups_at_[hidden]> wrote:
> > [...]
> > * What is your evaluation of the design?
> [...]
> In my design I allow the user to specify if a specific operator()
> overload should be disabled or not (depending on the arity and the
> parameter types); It is useful if you are using more than one
> forwarder in some complex composition (i.e. as base classes) and you
> need to disable ambiguous overload. I do not think
> Boost.Functional/Forward should necessarily provide this
> functionality, but it might be considered.

Almost forgot, I also allow to (optionally) specify an accessor to get
to the forwarded function object give this and also specify a
metafunction to get the result value for a specific overload. The
operator() definition of my forwarder (with pseudo vararg syntax)
looks something like this:

  template<typename Args...>
  typename my_result_of(Base(Args...>)::type
  operator()(Args... argn) const {
      return typename access::apply<Base(Args...)>::type()(*this)(argn...);

Where 'my_result_of' is a composition of metafunctions provided by the
user that does both SFINAE and type deduction, and 'access' is a
metafunction class provided by the user that returns a (stateless)
function object which in turn returns the object to be forwarded. The
default of course is to do respectively no SFINAE, forward to
result_of and static_cast to Base.

In particular 'access' is useful if you, for whatever reason, want to
reverse the inheritance order and use the CRTP.

Again, this is probably getting too complex for a simple utility.


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