From: Terje Slettebø (tslettebo_at_[hidden])
Date: 2002-08-11 09:32:09
>From: "David Abrahams" <dave_at_[hidden]>
>>From: "Terje Slettebø" <tslettebo_at_[hidden]>
>> This uses the same "rebind" method used in MPL, and with the help of Mat
>> Marcus, I've got this to work on MSVC 6, too. The "T::template apply<N>"
>> syntax gave an ICE without it.
>I hope you just used the built-in MPL "apply" metafunction to do that:
Yep, I did. :)
"value" is defined simply like this:
template<typename T, int N>
typedef typename apply1<T,int_c<N> >::type type;
To aid readability, the "apply1" is wrapped like this.
The "int_c" above is also just to wrap the value in a type, as "apply"
expects a type, not value.
This system requires a change in the value types, though, such as this:
template<typename T, T N>
BOOST_STATIC_CONSTANT(T, value = N);
typedef integral_c<T::value> type;
I earlier called the member template "rebind", but changed it to "apply", so
that it could be used with "apply1".
When I first made it, I didn't realize that capability was already in MPL
(with workaround for MSVC). However, I first tried it as explained in this
article (http://lists.boost.org/MailArchives/boost/msg20915.php), that Mat
pointed me to, for an explanation of a workaround. He also said I could use
mpl::apply for this, by reorganizing the code a little (as shown above), and
it worked fine, as you said, too.
It wasn't easy to find this, as I haven't found "apply" documented anywhere,
at least not in the reference docs
(http://www.mywikinet.com/mpl/ref/Table_of_Content.html). Is it documented
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk