Boost logo

Boost :

From: Dirk Gerrits (dirkg_at_[hidden])
Date: 2002-05-11 08:12:38


----- Original Message -----
From: "Giovanni Bajo" <giovannibajo_at_[hidden]>
To: <boost_at_[hidden]>
Sent: Saturday, 11 May, 2002 12:34
Subject: Re: [boost] Overloading a function taking a boost::function

> There are methods that work for normal functions but will fail on any
other
> type of "functors". For example, you can use partial template
specializion:
>
> template <typename FUNC>
> struct ArietyTrait;
>
> template <typename R>
> struct ArietyTrait<R (*)(void)>
> {
> // ....
> };
>
> template <typename R, typename P1>
> struct ArietyTrait<R (*)(P1)>
> {
> // ....
> };
>
> template <typename R, typename P1, typename P2>
> struct ArietyTrait<R (*)(P1, P2)>
> {
> // ....
> };
>
>
> With this trait, you can match functions with 0, 1, 2, etc parameters.

I appreciate your input, and this is indeed another way to look at the
problem. But I don't really thing it is easier to write ArietyTrait than
it is to write make_function. (It might be more reusable though???)

Also, I forgot to mention that I'm using MSVC6 so no partial specialization.
:(

Dirk Gerrits


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