Boost logo

Boost :

From: Aleksey Gurtovoy (agurtovoy_at_[hidden])
Date: 2003-09-10 17:05:28

Joaquín Mª López Muñoz wrote:
> This should have been posted to the Users list, but seems like
> it is temporarily disabled.

The Users list has been switched to Mailman, so you might have to
re-subscribe, depending on your previous membership settings -
please see

> Say I've got a MPL sequence whose elements
> contain a nested typedef "type_list" which is also a MPL sequence
> (so, a sequence of sequences). This algorithm looks for an element
> of such a sequence having a given type in its "type_list" typedef:
> template<typename TypeListofTypeLists,typename Type>
> struct find_type
> {
> typedef typename mpl::find_if<
> TypeListofTypeLists,
> mpl::bind1<has_type<Tag>,mpl::_1>

I suppose this should be


in which case I would write the whole thing as

    typedef typename mpl::find_if<
        , has_type
>::type iter;

> >::type iter;
> typedef typename iter::type type;
> };
> template<typename Type>
> struct has_type
> {
> template<typename TypeListofTypeListsElement>
> struct apply:mpl::contains<
> BOOST_DEDUCED_TYPENAME TypeListofTypeListsElement::type_list,
> Type>
> {};
> };

Hmm, one way to improve this one is to make
'TypeListofTypeListsElement::type_list' a set. Do you need a guarantee of
a particular iteration order on this sequence?

> This works but seems to make MSVC++ 6.0 choke under moderate
> stress. Any idea to simplify it? (unrolling, etc.) Thanx in advance

You can try out the simplified version above (without 'bind'), but I
guess to be able to suggest more options I need to know how does is
chokes :). Does it ICE, returns a wrong result, or something else?


Boost list run by bdawes at, gregod at, cpdaniel at, john at