
Imagine a template defined like this: template< class T, class U = void > struct foo {}; I would like to turn this into a metafunction class F such that: mpl::apply< F, int >::type ==> foo<int, void> and mpl::apply< F, int, float >::type ==> foo<int, float> Can this be done? If F is foo< _1, _2 >, then the first apply above won't compile because it hasn't been given enough arguments. -- Eric Niebler Boost Consulting www.boost-consulting.com

"Eric Niebler" <eric@boost-consulting.com> writes:
Imagine a template defined like this:
template< class T, class U = void > struct foo {};
I would like to turn this into a metafunction class F such that:
mpl::apply< F, int >::type ==> foo<int, void>
and
mpl::apply< F, int, float >::type ==> foo<int, float>
Can this be done? If F is foo< _1, _2 >, then the first apply above won't compile because it hasn't been given enough arguments.
template <class L, class D> struct default2nd { template <class A0, class A1 = D> struct apply : mpl::apply<L,A0,A1> {} }; default2nd< foo<_,_>, void> ? -- Dave Abrahams Boost Consulting www.boost-consulting.com
participants (2)
-
David Abrahams
-
Eric Niebler