Boost logo

Boost Users :

From: David Abrahams (dave_at_[hidden])
Date: 2005-06-14 16:07:38


"Stephen Gross" <mrstephengross_at_[hidden]> writes:

> (1) Where can I find reference information for mpl::for_each (I've looked
> around on the boost website and can't seem to find it).

Seems to be missing. Aleksey?

> (2) Here's what I'm trying to do: I've got an mpl::vector. Given some type
> T, I want to loop across the vector and see if T is convertible to any of
> the types in the vector.

If you want a compile-time result, for_each isn't going to help you.
for_each is designed to invoke a *runtime* function on each type in a
sequence.

Maybe

     template <class Sequence, class T>
     struct contains_convertible_type
       : mpl::not_<
            boost::is_same<
                typename mpl::find_if<
                    type_sequence
                  , boost::is_convertible<T,_1>
>::type
              , typename mpl::end<Sequence>::type
>
>
     {};

??

HTH,

-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com

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