Boost logo

Boost Users :

Subject: Re: [Boost-users] [mpl] Constant time mpl::contains<mpl::set>
From: Joel Falcou (joel.falcou_at_[hidden])
Date: 2010-03-29 02:35:11


strasser_at_[hidden] wrote:
> Hi,
>
> I'd like to be able to query if a MPL Sequence contains a certain type,
> aka mpl::contains.
> But mpl::contains is documented to always have linear complexity, even
> for mpl::set's. How can you differentiate between types of MPL
> Sequences, so you can use mpl::at for sets and mpl::contains for vectors?
> MPL itself seems to do this by template specialization, e.g. for
> mpl::at, which is overloaded.
> But template specialization relies on MPL implementation details, is
> there a way to detect any type that models an associative sequence?
> I can't find something like mpl::is_set nor a tag to dispatch with in
> the AssociativeSequence concept.
>
> Thank you,
>
> Stefan

I, myself, use :

http://www.boost.org/doc/libs/1_41_0/libs/mpl/doc/refmanual/sequence-tag.html

and I check if the returned type is one of the defined tag. HJere for
mpl::set, you can do is_same<sequence_tag<X>, sequence_tag< set<> > >
so you don't rely on the explicit type of the tag itself.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net