Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2003-11-11 07:39:09


Eric Friedman <ebf_at_[hidden]> writes:

>> At some point users need to learn to deal with the metafunction
>> idiom or we're going to be adding make_ to the beginning of every
>> metafunction name.
>
> I think there is an important difference between classes that are true
> metafunctions vs. those that are metafunctions only because of a lack
> of template typedefs.

Hmm: boost::type_with_alignment<N>::type

> That is, even if C++ today had template typedefs, I believe true
> metafunctions would not use the feature.
>
> [For instance, consider type traits and MPL algorithms. If these were
> template typedefs, then instantiation would occur immediately. This
> would prevent many good things, such as lambda expressions, etc. So
> even with the advent of template typedefs, I would hope true
> metafunctions would not use them.]
>
> On the other hand, if C++ had template typedefs, I would not want
> anyone to have to write:
>
> void f() {
> recursive_variant< ... >::type v;
> ...
> }

Why is lazy instantiation less useful for recursive_variant than for
other metafunctions?

> That recursive_variant is a metafunction is an implementation
> detail. Thus, it is a mistake, IMO, to expose this implementation
> detail to the user simply because of a deficiency in C++.
>
> In contrast, a name like 'make_recursive_variant' explicitly indicates
> a metafunction. Invoking this metafunction via ::type is no longer an
> implementation detail but rather integral to the metafunction idiom.

I understand your point.

recursive_variant_type<sequence>::type

??

-- 
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