From: David Abrahams (david.abrahams_at_[hidden])
Date: 2001-11-28 10:22:55
----- Original Message -----
From: "Hamish Mackenzie" <boost_at_[hidden]>
> On Wed, 2001-11-28 at 13:33, Vesa Karvonen wrote:
> > Partial specialization, or pattern matching, can be nice at times.
> > even FP people realize that pattern matching is rather inflexible.
> > algorithm (higher order function) using pattern matching ties the
> > a single data structure (such as a list). There are much more effective
> > to write reusable code.
> I think full specialization is broken in MPL too, does the following
> template< class T >
> class foo;
> class foo< boost::mpl::type_list< int, float > >
> int main()
> typdef boost::mpl::type_list< int > int_only;
> typdef boost::mpl::type_list< float > float_only;
> foo< boost::mpl::append< int_only, float_only >::sequence > x
Nope. But I was thinking of a simple idiom which would help. We could make a
simple metafunction which returns the underlying cons-list if type pass a
type_list, or the identity otherwise. Top-level metafunctions which want to
take advantage of specialization could pass their arguments through this
In any case, Vesa's point applies to full specialization just as to partial
specialization. It's still a pattern match, and your pattern can /only/
match type lists based on a particular underlying list node template.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk