template<typename... T>
struct boost::mpl::vector< T >
Adapter for Boost.MPL vectors.
Modeled concepts
It is possible for MPL vectors to model a couple of concepts. However, because they are only able to hold types, they lack the generality required to model concepts like Functor
, Sequence
and other related concepts.
Comparable
Two MPL vectors are equal if and only if they contain the same number of types, and if all those types are equal. hana::equal(mpl::vector2<int, char>{}, mpl::vector<int, char>{})
);
hana::not_equal(mpl::vector2<int, char>{}, mpl::vector<int, char, float>{})
);
int main() { }
Foldable
Folding a MPL vector is equivalent to folding it as a Sequence
. #include <type_traits>
auto types = mpl::vector<long, float, short, float, long, long double>{};
return hana::if_(hana::trait<std::is_floating_point>(t),
);
});
int main() { }
Iterable
Iterating over a MPL vector is just iterating over each of the types it contains, as if it were a Sequence
. #include <type_traits>
mpl::vector<char, void>{}
));
hana::trait<std::is_floating_point>),
mpl::vector<int, float&>{}
));
int main() { }
Searchable
A MPL vector can be searched as if it were a tuple containing hana::type
s. ==
hana::just(hana::type_c<float>)
);
hana::find(mpl::vector<int, float, char const*>{}, hana::type_c<void>)
==
hana::nothing
);
int main() { }
Conversion from any Foldable
A MPL vector can be created from any Foldable
. More precisely, for a Foldable
xs
whose linearization is [x1, ..., xn]
,
to<ext::boost::mpl::vector_tag>(xs) == mpl::vector<t1, ..., tn>
where tk
is the type of xk
, or the type contained in xk
if xk
is a hana::type
.
- Warning
- The limitations on the size of
mpl::vector
s are inherited by this conversion utility, and hence trying to convert a Foldable
containing more than BOOST_MPL_LIMIT_VECTOR_SIZE elements is an error. #include <type_traits>
auto xs = hana::make_tuple(hana::type_c<int>, hana::type_c<char>, hana::type_c<double>);
static_assert(std::is_same<
decltype(hana::to<hana::ext::boost::mpl::vector_tag>(xs)),
mpl::vector<int, char, double>
>{}, "");
int main() { }