[mpl] Constant time mpl::contains<mpl::set>

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

strasser@uni-bremen.de 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.htm...
and I check if the returned type is one of the defined tag. HJere for
mpl::set, you can do is_same
participants (2)
-
Joel Falcou
-
strasser@uni-bremen.de