Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2002-11-22 08:03:49


From: "David Abrahams" <dave_at_[hidden]>
> Sylvain Pion <Sylvain.Pion_at_[hidden]> writes:
>
[...]
> > Access to the arity is supposed to be done with an Arity_traits<>, so
that
> > it can be made to work with std:: functors as well, e.g. :
> >
> > template < class T >
> > struct Arity_traits< std::plus< T > > {
> > typedef Arity_tag< 2 > Arity;
> > };
>
> And that's supposed to be spelled:
>
> template < class T >
> struct Arity_traits< std::plus< T > > {
> typedef Arity_tag< 2 > type;
> };
>
> So that it can be used with MPL. But that's beside the point. Finding
> the arity is just one small piece of the puzzle. I need the types of
> all the arguments.

Looks like you'll have to define the standard interface. :-)

template<class F> struct arity_of; // ::value, ::type
template<class F> struct result_type_of; // ::type
template<class F, int I> struct argument_type_of; // ::type

On the function object side, the current

struct F
{
    typedef void result_type;
    enum { arity = 2 };
    typedef int arg1_type;
    typedef long const & arg2_type;
};

looks reasonable, but it might be interesting to explore the

struct F
{
    typedef void signature(int, long const &);
};

alternative. That's one of things I keep forgetting to suggest for
Boost(Std?).Function.


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