Boost logo

Boost Users :

From: Ovanes Markarian (om_boost_at_[hidden])
Date: 2007-06-19 10:21:34


[...]
> Thanks, iterator_range works fine. What's not very nice to me is the T typename is lost for empty
>sequence and after using a metafunction, so vector_c is not really usable for metaprograming, its
>just a macro to easier define a vector.

Well... Type never gets lost in C++ ;)

What about:

typedef mpl::vector_c<float, 2.0,2.1,2.2> my_vector;

BOOST_MPL_ASSERT(( is_same< mpl::front<my_vector>::type::value_type, float > ));

vector_c initializes a vector with integral_c derived type (like mpl::int_ or mpl::bool_) and
value specified, so in this example we have most probably an mpl::vector of integral_c<float,
2.0>,..., integral_c<float, 2.2>.

Anyway applying a front metafunction to any element of vector will return some integral_c<float,
X> specification. Since you are interested in type contained in integral_c you can access it via
integral_c<float, X>::value_type. Therefore:

mpl::front<my_vector>::type::value_type
                       ^^^^ ^^^^^ + => integral_c<float, X>::value_type
                       + => integral_c<float, X>
result in correct type resolution stored in mpl::vector.

Hope that helps.

With Kind Regards,

Ovanes Markarian


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