On 8/6/2011 3:47 AM, Mathias Gaunard wrote:
> On 08/06/2011 07:30 AM, Eric Niebler wrote:
>> On 8/5/2011 8:52 AM, Joel falcou wrote:
>>> There is few use case where I wish i can have a proto::switch_ like
>>> transform being extendable externally but based on something else than
>>> the expression tag like the result of an arbitrary meta-function.
>>> Is cloning proto::swicth_ and changing the way it dispatch over its
>>> internal cases_ enough ?
>> That wouldn't be enough because proto::matches "knows" about
>> proto::switch_. It would be easy enough to extend proto::switch_ to take
>> an optional mpl metafunction that accepts and expression and returns a
>> type to dispatch on. It would default to proto::tag_of<mpl::_>. Or for
>> the sake of consistency with the rest of proto, it should probably be a
>> transform, in which case it would default to proto::tag_of<proto::_>().
>> Could you open a feature request?
> Why not just add an extra class Enable = void template parameter to
> case_, which would allow to use SFINAE for case_ partial specializations?
> template<class Tag>
> struct case_<Tag, typename boost::enable_if< is_what_I_want<Tag> >::type>
> : ....
That doesn't change the fact that switch_ dispatches to the cases using
tag type, which may not be desired. Besides, enable_if is yuk.
proto mailing list