Boost logo

Boost :

From: Arturo_Cuebas_at_[hidden]
Date: 2004-08-23 16:13:29


BTW Jonathan, thanks for all your input.

> I think '()' look's funny :()

Me too. Just throwing it out there.
 
> I think Daniel James had the best idea:
>
> boost::overload<int>::resolve(&V::f)
 
I've learned to like it.

> [boost::function is] Too heavy-weight, I think. The other proposals
> probably have zero runtime overhead.

I thought this might be an issue. But it's a non-issue now because of
the tip you gave me with mpl::identity. :)

> What are P1, P2, P3 ... ?

The operator () definition that I showed is a member function of a class.
P1, P2, & P3 are template params of the class.
OTO:

template<typename P1, typename P2, typename P3>
struct overload_select
{
   // operator () def here.
};

OK. So now I'm thinking its final form would look something like:

class Nothing{};

template<typename P1 = Nothing,
         typename P2 = Nothing,
         typename P3 = Nothing,
         typename P4 = Nothing,
         typename P5 = Nothing,
         typename P6 = Nothing,
         typename P7 = Nothing,
         typename P8 = Nothing,
         typename P9 = Nothing>
struct overload
{
};
 
template<typename P1>
struct overload<P1,
               Nothing,
               Nothing,
               Nothing,
               Nothing,
               Nothing,
               Nothing,
               Nothing,
               Nothing>
{
   template <typename R>
   static typename boost::mpl::identity<R (*)(P1)>::type select (R (*
fp)(P1))
   {
      return fp;
   }
 
   template <typename R, typename C>
   static typename boost::mpl::identity<R (C::*)(P1)>::type select (R
(C::* fp)(P1))
   {
      return fp;
   }
};

// 8 more explicit specializations of overload here.

This compiles and works on VC7.1 at least.


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