Boost logo

Boost :

From: David Abrahams (david.abrahams_at_[hidden])
Date: 2001-12-05 11:05:42


Thanks, Peter. Moving the member function pointer into a typedef is the key
change:

template <class PMF>
void f(PMF f)
{
    some_template<PMF>... // error!
}

template <class PMF>
void f(PMF f)
{
    typedef PMF pmf;
    some_template<pmf>... // OK!
}

----- Original Message -----
From: "Peter Dimov" <pdimov_at_[hidden]>
To: <boost_at_[hidden]>
Sent: Wednesday, December 05, 2001 10:35 AM
Subject: Re: [boost] looking for a Borland metaprogramming hint

> #include <boost/static_assert.hpp>
> #include <cstddef>
>
> // Computes (at compile-time) the number of elements that a Python
> // argument tuple must have in order to be passed to a wrapped C++
> // (member) function of the given type.
>
> typedef char (&a1) [1];
> typedef char (&a2) [2];
>
> template<class R> a1 f(R (*)());
> template<class R, class T> a2 f(R (T::*)());
>
> template <class F> struct arg_tuple_size
> {
> enum { value = sizeof(f(F())) - 1 };
> };
>
> struct X
> {
> };
>
> int main()
> {
> typedef void (X::*pmf_type)();
>
> enum { v = arg_tuple_size<pmf_type>::value };
>
> BOOST_STATIC_ASSERT(v == 1);
>
> return 0;
> }
>
> --
> Peter Dimov
> Multi Media Ltd.
>
>
> Info: http://www.boost.org Send unsubscribe requests to:
<mailto:boost-unsubscribe_at_[hidden]>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>


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