Boost logo

Boost :

From: Jaap Suter (boost_at_[hidden])
Date: 2005-01-27 21:35:17


> I was trying to use mpl::contains with list_c and it always seems to
> return mpl::false_.

> For example
> typedef mpl::list_c< int ,16,8 > mylist;
> typedef mpl::contains<mylist, mpl::int_<16> >::type tt;

I've run into this issue in the past as well, and I vaguely rememember
seeing mpl::integral_c<long>'s being used somewhere along the way, instead
of mpl::integral_c<int>'s as one would expect. I'm not sure if that is still
the case, or whether I was decaffeinated, but I ended up fixing it by using
the following work-around (pseudo-code):

    template<class Sequence, class Elem>
    struct contains : mpl::contains
    <
        Sequence,
        mpl::integral_c
        <
            mpl::front<Sequence>::value_type,
            Elem::value>
>
>{};

Which isn't pretty, but it got the job done. You basically get the
value_type of the first element in the sequence, to make sure the base type
of the integral_c you're looking for matches with the sequence.

I'm hoping Alexsey or Dave will step in here and clarify this, as it has
been a source of confusion for me as well.

Regards,

Jaap Suter


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk