|
Boost : |
From: Fernando Cacciola (fcacciola_at_[hidden])
Date: 2001-12-05 10:43:27
----- Original Message -----
From: David Abrahams <david.abrahams_at_[hidden]>
To: <boost_at_[hidden]>
Sent: Wednesday, December 05, 2001 12:18 PM
Subject: Re: [boost] looking for a Borland metaprogramming hint
>
> ----- Original Message -----
> From: "Fernando Cacciola" <fcacciola_at_[hidden]>
> > Could you post a complete example?.
> > If I test the above with a "detail::arg_tuple_size<T>::value" equal to
> > "sizeof(T)" it compiles fine.
>
> Voila. I can't get the no-partial-specialization branch of the code to
work
> with Borland either:
>
Here is what I found:
1) The partial specialization code is ill-formed.
Look here:
(A) template <class F> struct arg_tuple_size;
(B) template <class R, class A0> struct arg_tuple_size<R (A0::*)()> ....
(B) is a specialization of (A), but it is *adding* a second template
argument.
Unfortunately, we can only do it the other way around.
2) If I change the example so that it uses the non partial specialization
trick:
2.1) Borland doesn't like the expression "void (X::*)()" as a
template argument "on the fly". But you can typedef'it first:
typedef void (X::*mfun_t)();
arg_tuple_size<mfun_t>::value;
2.2) Borland does't like the exression "tuple_size =
arg_tuple_size<mfun_t>::value == 1",
so you need to define the 'tuple size' elsewhere:
BOOST_STATIC_CONSTANT(std::size_t, tuple_size =
arg_tuple_size<mfun_t>::value);
BOOST_STATIC_ASSERT(tuple_size == 1);
So, in order to make it work you need to do it like this:
*/
struct X {};
int main()
{
typedef void (X::*mfun_t)();
BOOST_STATIC_CONSTANT(std::size_t, tuple_size =
arg_tuple_size<mfun_t>::value);
BOOST_STATIC_ASSERT(tuple_size == 1);
return 0;
}
Fernando Cacciola
Sierra s.r.l.
fcacciola_at_[hidden]
www.gosierra.com
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk