/*! @file Adapts `boost::mpl::vector` for use with Hana. @copyright Louis Dionne 2013-2017 Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) */ #ifndef BOOST_HANA_EXT_BOOST_MPL_VECTOR_HPP #define BOOST_HANA_EXT_BOOST_MPL_VECTOR_HPP #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #ifdef BOOST_HANA_DOXYGEN_INVOKED namespace boost { namespace mpl { //! @ingroup group-ext-mpl //! 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. //! //! 1. `Comparable`\n //! Two MPL vectors are equal if and only if they contain the same //! number of types, and if all those types are equal. //! @include example/ext/boost/mpl/vector/comparable.cpp //! //! 2. `Foldable`\n //! Folding a MPL vector is equivalent to folding it as a `Sequence`. //! @include example/ext/boost/mpl/vector/foldable.cpp //! //! 3. `Iterable`\n //! Iterating over a MPL vector is just iterating over each of the //! types it contains, as if it were a `Sequence`. //! @include example/ext/boost/mpl/vector/iterable.cpp //! //! 4. `Searchable`\n //! A MPL vector can be searched as if it were a tuple containing //! `hana::type`s. //! @include example/ext/boost/mpl/vector/searchable.cpp //! //! //! Conversion from any `Foldable` //! ------------------------------ //! A MPL vector can be created from any `Foldable`. More precisely, //! for a `Foldable` `xs` whose linearization is `[x1, ..., xn]`, //! @code //! to(xs) == mpl::vector //! @endcode //! 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][1] elements //! is an error. //! @include example/ext/boost/mpl/vector/conversion.cpp //! //! [1]: http://www.boost.org/doc/libs/release/libs/mpl/doc/refmanual/limit-vector-size.html template struct vector { }; }} #endif BOOST_HANA_NAMESPACE_BEGIN namespace ext { namespace boost { namespace mpl { using vector_tag = ::boost::mpl::sequence_tag< ::boost::mpl::vector<>>::type; }}} namespace mpl_detail { // When `BOOST_MPL_CFG_TYPEOF_BASED_SEQUENCES` is not defined (e.g. on // MSVC), different MPL sequences (like vector0 and vector1) have different // tags, so we need to take that into account when we compare them. #ifndef BOOST_MPL_CFG_TYPEOF_BASED_SEQUENCES template struct is_same_mpl_vector_tag : std::false_type { }; template