|
Boost : |
From: Eric Friedman (ebf_at_[hidden])
Date: 2003-11-15 20:33:02
Peter Dimov wrote:
> I'm somewhat amused by the possibilities that enable_if offers. Perhaps one
> day we'll think of
>
> template<class V> enable_if< is_instance_of< std::vector<_, _>, V> >::type
> f( V & v);
>
> as a natural alternative to
>
> template<class T, class A> void f( std::vector<T, A> & v );
>
> but I doubt it. ;-)
If we ever do, we can use mpl::lambda_match, which is in the sandbox:
template <class V>
typename enable_if<
mpl::lambda_match< std::vector<_,_>, V >
>::type
f( V & v );
Additionally, lambda_match supports more advanced functionality, such as
template <class Double>
typename enable_if<
mpl::lambda_match< std::pair<_1,_1>, Double >
>::type
f( Double & d );
Perhaps I should rename it to mpl::is_instance_of?
Eric
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk