|
Boost : |
From: David Abrahams (dave_at_[hidden])
Date: 2006-10-14 16:20:10
"Eric Niebler" <eric_at_[hidden]> 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
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk