|
Boost : |
Subject: Re: [boost] [mpl] sequence_tag
From: David Abrahams (dave_at_[hidden])
Date: 2009-01-13 14:04:56
on Tue Jan 13 2009, Eric Niebler <eric-AT-boost-consulting.com> wrote:
> A type is an mpl sequence if mpl::sequence_tag<T>::type is something other than
> mpl::non_sequence_tag. There are a few ways of hooking mpl::sequence_tag, but the
> easiest is for T to have a nested typedef named "tag". I find this
> unfortunate. Consider proto expression types, which, in addition to being nodes in
> expression trees, are also both fusion sequences and mpl sequences.
>
> A proto expression type has three tag types associated with it:
> 1) The Proto tag (e.g., proto::tag::plus), a nested typedef
> named "proto_tag"
> 2) The Fusion tag, a nested typedef named "fusion_tag"
> 3) The MPL tag
>
> I can't in good conscience use a nested typedef named "tag" for the MPL tag because
> that would lead to confusion. It would be nice if MPL had instead chosen the name
> "mpl_tag" for its tag type. It's not too late to make the change ... MPL could first
> look for "mpl_tag" before falling back on "tag".
>
> For now, I have chosen to specialize mpl::sequence_tag for the proto::expr type. This
> is an incomplete solution because types that extend proto::expr are not themselves
> automatically MPL sequences. Another solution might be to allow SFINAE on
> sequence_tag, like ...
>
> template<typename T, typename EnableIf = void>
> struct sequence_tag;
>
> That way I could partially specialize for proto expression types, like:
>
> template<typename T, typename enable_if<proto::is_expr<T> >::type>
> struct sequence_tag { ...
>
> Thoughts? FWIW, I'd prefer MPL to rename the nested tag typedef to "mpl_tag".
I've no objections. Aleksey?
-- Dave Abrahams BoostPro Computing http://www.boostpro.com
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk