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.
namespace mpl = boost::mpl;
hana::equal(mpl::vector2<int, char>{}, mpl::vector<int, char>{})
);
hana::not_equal(mpl::vector2<int, char>{}, mpl::vector<int, char, float>{})
);
int main() { }
Defines macros to perform different kinds of assertions.
Adapts boost::mpl::vector for use with Hana.
Defines boost::hana::equal.
constexpr auto equal
Returns a Logical representing whether x is equal to y.
Definition: equal.hpp:64
constexpr auto not_equal
Returns a Logical representing whether x is not equal to y.
Definition: not_equal.hpp:54
#define BOOST_HANA_CONSTANT_CHECK(...)
Equivalent to BOOST_HANA_CONSTANT_ASSERT, but not influenced by the BOOST_HANA_CONFIG_DISABLE_ASSERTI...
Definition: assert.hpp:239
Namespace containing everything in the library.
Definition: accessors.hpp:20
Defines boost::hana::not_equal.
Foldable
Folding a MPL vector is equivalent to folding it as a Sequence
.
#include <type_traits>
namespace mpl = boost::mpl;
auto types = mpl::vector<long, float, short, float, long, long double>{};
auto number_of_floats = hana::fold_left(types, hana::int_c<0>, [](
auto count,
auto t) {
return hana::if_(hana::trait<std::is_floating_point>(t),
);
});
int main() { }
Adapts std::integral_constant for use with Hana.
Defines boost::hana::fold_left.
constexpr auto count
Return the number of elements in the structure that compare equal to a given value.
Definition: count.hpp:41
constexpr auto if_
Conditionally return one of two values based on a condition.
Definition: if.hpp:41
Defines boost::hana::if_.
Defines boost::hana::integral_constant.
Defines boost::hana::plus.
Defines boost::hana::type and related utilities.
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>
namespace mpl = boost::mpl;
mpl::vector<char, void>{}
));
hana::trait<std::is_floating_point>),
mpl::vector<int, float&>{}
));
int main() { }
Defines boost::hana::drop_front.
Defines boost::hana::drop_while.
Defines boost::hana::front.
constexpr auto front
Returns the first element of a non-empty iterable.
Definition: front.hpp:32
constexpr auto drop_while
Drop elements from an iterable up to, but excluding, the first element for which the predicate is not...
Definition: drop_while.hpp:44
constexpr auto drop_front
Drop the first n elements of an iterable, and return the rest.
Definition: drop_front.hpp:47
Searchable
A MPL vector can be searched as if it were a tuple containing hana::type
s.
namespace mpl = boost::mpl;
==
hana::just(hana::type_c<float>)
);
hana::find(mpl::vector<int, float, char const*>{}, hana::type_c<void>)
==
hana::nothing
);
int main() { }
Defines boost::hana::find.
Defines boost::hana::find_if.
constexpr auto find
Finds the value associated to the given key in a structure.
Definition: find.hpp:44
constexpr auto find_if
Finds the value associated to the first key satisfying a predicate.
Definition: find_if.hpp:41
Defines boost::hana::optional.
Conversion from any <tt>Foldable</tt>
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>
namespace mpl = boost::mpl;
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() { }
Defines boost::hana::to and related utilities.
Defines boost::hana::tuple.