stabilize build system: depends, installer, boost/bdb fixes, cross targets groundwork

This commit is contained in:
2026-02-24 18:38:47 +00:00
parent da8c28aaeb
commit 65cb2619a7
13106 changed files with 2484322 additions and 1804 deletions
@@ -0,0 +1,22 @@
/*!
@file
Includes all the adaptors for the Boost.Fusion library.
@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_FUSION_HPP
#define BOOST_HANA_EXT_BOOST_FUSION_HPP
//! @ingroup group-ext
//! @defgroup group-ext-fusion Boost.Fusion adapters
//! Adapters for Boost.Fusion containers.
#include <boost/hana/ext/boost/fusion/deque.hpp>
#include <boost/hana/ext/boost/fusion/list.hpp>
#include <boost/hana/ext/boost/fusion/tuple.hpp>
#include <boost/hana/ext/boost/fusion/vector.hpp>
#endif // !BOOST_HANA_EXT_BOOST_FUSION_HPP
@@ -0,0 +1,108 @@
/*!
@file
Adapts `boost::fusion::deque` 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_FUSION_DEQUE_HPP
#define BOOST_HANA_EXT_BOOST_FUSION_DEQUE_HPP
#include <boost/hana/at.hpp>
#include <boost/hana/core/when.hpp>
#include <boost/hana/config.hpp>
#include <boost/hana/ext/boost/fusion/detail/common.hpp>
#include <boost/hana/fwd/core/make.hpp>
#include <boost/hana/fwd/core/tag_of.hpp>
#include <boost/hana/fwd/drop_front.hpp>
#include <boost/hana/length.hpp>
#include <boost/fusion/container/deque.hpp>
#include <boost/fusion/container/generation/make_deque.hpp>
#include <boost/fusion/support/tag_of.hpp>
#include <cstddef>
#include <type_traits>
#include <utility>
#ifdef BOOST_HANA_DOXYGEN_INVOKED
namespace boost { namespace fusion {
//! @ingroup group-ext-fusion
//! Adapter for Boost.Fusion deques.
//!
//!
//! Modeled concepts
//! ----------------
//! A Fusion deque is a model of the `Sequence` concept, and all the
//! concepts it refines. That makes it essentially the same as a Hana
//! tuple, although the complexity of some operations might differ from
//! that of a tuple.
//!
//! @include example/ext/boost/fusion/deque.cpp
template <typename ...T>
struct deque { };
}}
#endif
BOOST_HANA_NAMESPACE_BEGIN
namespace ext { namespace boost { namespace fusion {
struct deque_tag;
}}}
template <typename T>
struct tag_of<T, when<
std::is_same<
typename ::boost::fusion::traits::tag_of<T>::type,
::boost::fusion::traits::tag_of<
::boost::fusion::deque<>
>::type
>::value
>> {
using type = ext::boost::fusion::deque_tag;
};
namespace detail {
template <>
struct is_fusion_sequence<ext::boost::fusion::deque_tag> {
static constexpr bool value = true;
};
}
//////////////////////////////////////////////////////////////////////////
// Iterable (the rest is in detail/common.hpp)
//////////////////////////////////////////////////////////////////////////
template <>
struct drop_front_impl<ext::boost::fusion::deque_tag> {
template <std::size_t n, typename Xs, std::size_t ...i>
static constexpr auto drop_front_helper(Xs&& xs, std::index_sequence<i...>) {
return hana::make<ext::boost::fusion::deque_tag>(
hana::at_c<n + i>(static_cast<Xs&&>(xs))...
);
}
template <typename Xs, typename N>
static constexpr auto apply(Xs&& xs, N const&) {
constexpr std::size_t n = N::value;
constexpr std::size_t len = decltype(hana::length(xs))::value;
return drop_front_helper<n>(static_cast<Xs&&>(xs),
std::make_index_sequence<(n < len ? len - n : 0)>{});
}
};
//////////////////////////////////////////////////////////////////////////
// Sequence
//////////////////////////////////////////////////////////////////////////
template <>
struct make_impl<ext::boost::fusion::deque_tag> {
template <typename ...Xs>
static constexpr auto apply(Xs&& ...xs) {
return ::boost::fusion::make_deque(static_cast<Xs&&>(xs)...);
}
};
BOOST_HANA_NAMESPACE_END
#endif // !BOOST_HANA_EXT_BOOST_FUSION_DEQUE_HPP
@@ -0,0 +1,79 @@
/*!
@file
Defines common methods for all Boost.Fusion sequences.
@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_FUSION_DETAIL_COMMON_HPP
#define BOOST_HANA_EXT_BOOST_FUSION_DETAIL_COMMON_HPP
#include <boost/hana/bool.hpp>
#include <boost/hana/config.hpp>
#include <boost/hana/core/when.hpp>
#include <boost/hana/fwd/at.hpp>
#include <boost/hana/fwd/concept/sequence.hpp>
#include <boost/hana/fwd/is_empty.hpp>
#include <boost/hana/fwd/length.hpp>
#include <boost/hana/integral_constant.hpp>
#include <boost/fusion/sequence/intrinsic/at.hpp>
#include <boost/fusion/sequence/intrinsic/empty.hpp>
#include <boost/fusion/sequence/intrinsic/size.hpp>
#include <cstddef>
BOOST_HANA_NAMESPACE_BEGIN
namespace detail {
template <typename T>
struct is_fusion_sequence {
static constexpr bool value = false;
};
}
//////////////////////////////////////////////////////////////////////////
// Iterable
//////////////////////////////////////////////////////////////////////////
template <typename S>
struct at_impl<S, when<detail::is_fusion_sequence<S>::value>> {
template <typename Xs, typename N>
static constexpr decltype(auto) apply(Xs&& xs, N const&) {
constexpr std::size_t n = N::value;
return boost::fusion::at_c<n>(static_cast<Xs&&>(xs));
}
};
template <typename S>
struct is_empty_impl<S, when<detail::is_fusion_sequence<S>::value>> {
template <typename Xs>
static constexpr auto apply(Xs&& xs) {
using Empty = decltype(boost::fusion::empty(xs));
return hana::bool_c<Empty::value>;
}
};
//////////////////////////////////////////////////////////////////////////
// Foldable
//////////////////////////////////////////////////////////////////////////
template <typename S>
struct length_impl<S, when<detail::is_fusion_sequence<S>::value>> {
template <typename Xs>
static constexpr auto apply(Xs const&) {
using Size = typename boost::fusion::result_of::size<Xs>::type;
return hana::size_c<Size::value>;
}
};
//////////////////////////////////////////////////////////////////////////
// Sequence
//////////////////////////////////////////////////////////////////////////
template <typename S>
struct Sequence<S, when<detail::is_fusion_sequence<S>::value>> {
static constexpr bool value = true;
};
BOOST_HANA_NAMESPACE_END
#endif // !BOOST_HANA_EXT_BOOST_FUSION_DETAIL_COMMON_HPP
@@ -0,0 +1,111 @@
/*!
@file
Adapts `boost::fusion::list` 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_FUSION_LIST_HPP
#define BOOST_HANA_EXT_BOOST_FUSION_LIST_HPP
#include <boost/hana/config.hpp>
#include <boost/hana/core/when.hpp>
#include <boost/hana/ext/boost/fusion/detail/common.hpp>
#include <boost/hana/fwd/at.hpp>
#include <boost/hana/fwd/core/make.hpp>
#include <boost/hana/fwd/core/tag_of.hpp>
#include <boost/hana/fwd/drop_front.hpp>
#include <boost/hana/fwd/length.hpp>
#include <boost/fusion/algorithm/transformation/pop_front.hpp>
#include <boost/fusion/container/generation/make_list.hpp>
#include <boost/fusion/container/list.hpp>
#include <boost/fusion/container/list/convert.hpp>
#include <boost/fusion/support/tag_of.hpp>
#include <boost/version.hpp>
#include <cstddef>
#include <type_traits>
#include <utility>
#ifdef BOOST_HANA_DOXYGEN_INVOKED
namespace boost { namespace fusion {
//! @ingroup group-ext-fusion
//! Adapter for Boost.Fusion lists.
//!
//!
//! Modeled concepts
//! ----------------
//! A Fusion list is a model of the `Sequence` concept, and all the
//! concepts it refines. That makes it essentially the same as a Hana
//! tuple, although the complexity of some operations might differ from
//! that of a tuple.
//!
//! @include example/ext/boost/fusion/list.cpp
template <typename ...T>
struct list { };
}}
#endif
BOOST_HANA_NAMESPACE_BEGIN
namespace ext { namespace boost { namespace fusion {
struct list_tag;
}}}
template <typename T>
struct tag_of<T, when<
std::is_same<
typename ::boost::fusion::traits::tag_of<T>::type,
::boost::fusion::traits::tag_of<
::boost::fusion::list<>
>::type
>::value
>> {
using type = ext::boost::fusion::list_tag;
};
namespace detail {
template <>
struct is_fusion_sequence<ext::boost::fusion::list_tag> {
static constexpr bool value = true;
};
}
//////////////////////////////////////////////////////////////////////////
// Iterable (the rest is in detail/common.hpp)
//////////////////////////////////////////////////////////////////////////
template <>
struct drop_front_impl<ext::boost::fusion::list_tag> {
template <std::size_t n, typename Xs, std::size_t ...i>
static constexpr auto drop_front_helper(Xs&& xs, std::index_sequence<i...>) {
return hana::make<ext::boost::fusion::list_tag>(
hana::at_c<n + i>(static_cast<Xs&&>(xs))...
);
}
template <typename Xs, typename N>
static constexpr auto apply(Xs&& xs, N const&) {
constexpr std::size_t n = N::value;
constexpr std::size_t len = decltype(hana::length(xs))::value;
return drop_front_helper<n>(static_cast<Xs&&>(xs),
std::make_index_sequence<(n < len ? len - n : 0)>{});
}
};
//////////////////////////////////////////////////////////////////////////
// Sequence
//////////////////////////////////////////////////////////////////////////
template <>
struct make_impl<ext::boost::fusion::list_tag> {
template <typename ...Xs>
static constexpr auto apply(Xs&& ...xs) {
return ::boost::fusion::make_list(static_cast<Xs&&>(xs)...);
}
};
BOOST_HANA_NAMESPACE_END
#endif // !BOOST_HANA_EXT_BOOST_FUSION_LIST_HPP
@@ -0,0 +1,49 @@
/*!
@file
Adapts `boost::fusion::tuple` for use with Hana.
In the current version of Boost.Fusion, `boost::fusion::tuple` is basically
an alias to `boost::fusion::vector`, so both data types share the same
implementation in 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_FUSION_TUPLE_HPP
#define BOOST_HANA_EXT_BOOST_FUSION_TUPLE_HPP
#include <boost/hana/config.hpp>
#include <boost/hana/ext/boost/fusion/vector.hpp>
#ifdef BOOST_HANA_DOXYGEN_INVOKED
namespace boost { namespace fusion {
//! @ingroup group-ext-fusion
//! Adapter for Boost.Fusion tuples.
//!
//!
//! Modeled concepts
//! ----------------
//! A Fusion tuple is a model of the `Sequence` concept, and all the
//! concepts it refines. That makes it essentially the same as a Hana
//! tuple, although the complexity of some operations might differ from
//! that of a tuple.
//!
//! @include example/ext/boost/fusion/tuple.cpp
template <typename ...T>
struct tuple { };
}}
#endif
BOOST_HANA_NAMESPACE_BEGIN
namespace ext { namespace boost { namespace fusion {
// In the current version of Boost.Fusion, `boost::fusion::tuple` is
// basically an alias to `boost::fusion::vector`, hence the alias.
using tuple_tag = vector_tag;
}}}
BOOST_HANA_NAMESPACE_END
#endif // !BOOST_HANA_EXT_BOOST_FUSION_TUPLE_HPP
@@ -0,0 +1,110 @@
/*!
@file
Adapts `boost::fusion::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_FUSION_VECTOR_HPP
#define BOOST_HANA_EXT_BOOST_FUSION_VECTOR_HPP
#include <boost/hana/config.hpp>
#include <boost/hana/core/when.hpp>
#include <boost/hana/ext/boost/fusion/detail/common.hpp>
#include <boost/hana/fwd/at.hpp>
#include <boost/hana/fwd/core/make.hpp>
#include <boost/hana/fwd/core/tag_of.hpp>
#include <boost/hana/fwd/drop_front.hpp>
#include <boost/hana/fwd/length.hpp>
#include <boost/fusion/algorithm/transformation/pop_front.hpp>
#include <boost/fusion/container/generation/make_vector.hpp>
#include <boost/fusion/container/vector.hpp>
#include <boost/fusion/container/vector/convert.hpp>
#include <boost/fusion/support/tag_of.hpp>
#include <cstddef>
#include <type_traits>
#include <utility>
#ifdef BOOST_HANA_DOXYGEN_INVOKED
namespace boost { namespace fusion {
//! @ingroup group-ext-fusion
//! Adapter for Boost.Fusion vectors.
//!
//!
//! Modeled concepts
//! ----------------
//! A Fusion vector is a model of the `Sequence` concept, and all the
//! concepts it refines. That makes it essentially the same as a Hana
//! tuple, although the complexity of some operations might differ from
//! that of a tuple.
//!
//! @include example/ext/boost/fusion/vector.cpp
template <typename ...T>
struct vector { };
}}
#endif
BOOST_HANA_NAMESPACE_BEGIN
namespace ext { namespace boost { namespace fusion {
struct vector_tag;
}}}
template <typename T>
struct tag_of<T, when<
std::is_same<
typename ::boost::fusion::traits::tag_of<T>::type,
::boost::fusion::traits::tag_of<
::boost::fusion::vector<>
>::type
>::value
>> {
using type = ext::boost::fusion::vector_tag;
};
namespace detail {
template <>
struct is_fusion_sequence<ext::boost::fusion::vector_tag> {
static constexpr bool value = true;
};
}
//////////////////////////////////////////////////////////////////////////
// Iterable (the rest is in detail/common.hpp)
//////////////////////////////////////////////////////////////////////////
template <>
struct drop_front_impl<ext::boost::fusion::vector_tag> {
template <std::size_t n, typename Xs, std::size_t ...i>
static constexpr auto drop_front_helper(Xs&& xs, std::index_sequence<i...>) {
return hana::make<ext::boost::fusion::vector_tag>(
hana::at_c<n + i>(static_cast<Xs&&>(xs))...
);
}
template <typename Xs, typename N>
static constexpr auto apply(Xs&& xs, N const&) {
constexpr std::size_t n = N::value;
constexpr std::size_t len = decltype(hana::length(xs))::value;
return drop_front_helper<n>(static_cast<Xs&&>(xs),
std::make_index_sequence<(n < len ? len - n : 0)>{});
}
};
//////////////////////////////////////////////////////////////////////////
// Sequence
//////////////////////////////////////////////////////////////////////////
template <>
struct make_impl<ext::boost::fusion::vector_tag> {
template <typename ...Xs>
static constexpr auto apply(Xs&& ...xs) {
return ::boost::fusion::make_vector(static_cast<Xs&&>(xs)...);
}
};
BOOST_HANA_NAMESPACE_END
#endif // !BOOST_HANA_EXT_BOOST_FUSION_VECTOR_HPP
@@ -0,0 +1,21 @@
/*!
@file
Includes all the adaptors for the Boost.MPL library.
@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_HPP
#define BOOST_HANA_EXT_BOOST_MPL_HPP
//! @ingroup group-ext
//! @defgroup group-ext-mpl Boost.MPL adapters
//! Adapters for Boost.MPL containers.
#include <boost/hana/ext/boost/mpl/integral_c.hpp>
#include <boost/hana/ext/boost/mpl/list.hpp>
#include <boost/hana/ext/boost/mpl/vector.hpp>
#endif // !BOOST_HANA_EXT_BOOST_MPL_HPP
@@ -0,0 +1,81 @@
/*!
@file
Adapts Boost.MPL IntegralConstants 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_INTEGRAL_C_HPP
#define BOOST_HANA_EXT_BOOST_MPL_INTEGRAL_C_HPP
#include <boost/hana/concept/integral_constant.hpp>
#include <boost/hana/config.hpp>
#include <boost/hana/core/tag_of.hpp>
#include <boost/hana/core/when.hpp>
#include <boost/hana/fwd/core/to.hpp>
#include <boost/mpl/integral_c.hpp>
#include <boost/mpl/integral_c_tag.hpp>
#include <type_traits>
#ifdef BOOST_HANA_DOXYGEN_INVOKED
namespace boost { namespace mpl {
//! @ingroup group-ext-mpl
//! Adapter for IntegralConstants from the Boost.MPL.
//!
//! Provided models
//! ---------------
//! 1. `Constant` and `IntegralConstant`\n
//! A Boost.MPL IntegralConstant is a model of the `IntegralConstant`
//! and `Constant` concepts just like `hana::integral_constant`s are.
//! As a consequence, they are also implicitly a model of the concepts
//! provided for all models of `Constant`.
//! @include example/ext/boost/mpl/integral_c/integral_constant.cpp
template <typename T, T v>
struct integral_c { };
}}
#endif
BOOST_HANA_NAMESPACE_BEGIN
namespace ext { namespace boost { namespace mpl {
template <typename T>
struct integral_c_tag { using value_type = T; };
}}}
template <typename T>
struct tag_of<T, when<
std::is_same<
typename T::tag,
::boost::mpl::integral_c_tag
>::value
>> {
using type = ext::boost::mpl::integral_c_tag<
typename hana::tag_of<typename T::value_type>::type
>;
};
//////////////////////////////////////////////////////////////////////////
// IntegralConstant/Constant
//////////////////////////////////////////////////////////////////////////
template <typename T>
struct IntegralConstant<ext::boost::mpl::integral_c_tag<T>> {
static constexpr bool value = true;
};
template <typename T, typename C>
struct to_impl<ext::boost::mpl::integral_c_tag<T>, C,
when<hana::IntegralConstant<C>::value>
> : embedding<is_embedded<typename C::value_type, T>::value> {
template <typename N>
static constexpr auto apply(N const&) {
return ::boost::mpl::integral_c<T, N::value>{};
}
};
BOOST_HANA_NAMESPACE_END
#endif // !BOOST_HANA_EXT_BOOST_MPL_INTEGRAL_C_HPP
@@ -0,0 +1,186 @@
/*!
@file
Adapts `boost::mpl::list` 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_LIST_HPP
#define BOOST_HANA_EXT_BOOST_MPL_LIST_HPP
#include <boost/hana/concept/foldable.hpp>
#include <boost/hana/config.hpp>
#include <boost/hana/core/when.hpp>
#include <boost/hana/ext/boost/mpl/integral_c.hpp>
#include <boost/hana/fwd/at.hpp>
#include <boost/hana/fwd/core/to.hpp>
#include <boost/hana/fwd/core/tag_of.hpp>
#include <boost/hana/fwd/drop_front.hpp>
#include <boost/hana/fwd/equal.hpp>
#include <boost/hana/fwd/is_empty.hpp>
#include <boost/hana/fwd/less.hpp>
#include <boost/hana/integral_constant.hpp>
#include <boost/hana/length.hpp>
#include <boost/hana/type.hpp>
#include <boost/hana/unpack.hpp>
#include <boost/mpl/at.hpp>
#include <boost/mpl/empty.hpp>
#include <boost/mpl/equal.hpp>
#include <boost/mpl/list.hpp>
#include <boost/mpl/sequence_tag.hpp>
#include <boost/mpl/size.hpp>
#include <cstddef>
#include <type_traits>
#include <utility>
#ifdef BOOST_HANA_DOXYGEN_INVOKED
namespace boost { namespace mpl {
//! @ingroup group-ext-mpl
//! Adapter for Boost.MPL lists.
//!
//!
//! Modeled concepts
//! ----------------
//! It is possible for MPL lists 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 lists 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/list/comparable.cpp
//!
//! 2. `Foldable`\n
//! Folding a MPL list is equivalent to folding it as a `Sequence`.
//! @include example/ext/boost/mpl/list/foldable.cpp
//!
//! 3. `Iterable`\n
//! Iterating over a MPL list is just iterating over each of the
//! types it contains, as if it were a `Sequence`.
//! @include example/ext/boost/mpl/list/iterable.cpp
//!
//! 4. `Searchable`\n
//! A MPL list can be searched as if it were a tuple containing
//! `hana::type`s.
//! @include example/ext/boost/mpl/list/searchable.cpp
//!
//!
//! Conversion from any `Foldable`
//! ------------------------------
//! A MPL list can be created from any `Foldable`. More precisely,
//! for a `Foldable` `xs` whose linearization is `[x1, ..., xn]`,
//! @code
//! to<ext::boost::mpl::list_tag>(xs) == mpl::list<t1, ..., tn>{}
//! @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::list`s are inherited by
//! this conversion utility, and hence trying to convert a `Foldable`
//! containing more than [BOOST_MPL_LIMIT_LIST_SIZE][1] elements is
//! an error.
//! @include example/ext/boost/mpl/list/conversion.cpp
//!
//! [1]: http://www.boost.org/doc/libs/release/libs/mpl/doc/refmanual/limit-list-size.html
template <typename ...T>
struct list { };
}}
#endif
BOOST_HANA_NAMESPACE_BEGIN
namespace ext { namespace boost { namespace mpl {
using list_tag = ::boost::mpl::sequence_tag< ::boost::mpl::list<>>::type;
}}}
template <typename T>
struct tag_of<T, when<
std::is_same<
typename ::boost::mpl::sequence_tag<T>::type,
::boost::mpl::sequence_tag< ::boost::mpl::list<>>::type
>::value
>> {
using type = ext::boost::mpl::list_tag;
};
//////////////////////////////////////////////////////////////////////////
// Comparable
//////////////////////////////////////////////////////////////////////////
template <>
struct equal_impl<ext::boost::mpl::list_tag, ext::boost::mpl::list_tag> {
template <typename Xs, typename Ys>
static constexpr auto apply(Xs const&, Ys const&) {
return typename ::boost::mpl::equal<Xs, Ys>::type{};
}
};
//////////////////////////////////////////////////////////////////////////
// Foldable
//////////////////////////////////////////////////////////////////////////
template <>
struct length_impl<ext::boost::mpl::list_tag> {
template <typename Xs>
static constexpr auto apply(Xs const&) {
return hana::size_c< ::boost::mpl::size<Xs>::type::value>;
}
};
//////////////////////////////////////////////////////////////////////////
// Iterable
//////////////////////////////////////////////////////////////////////////
template <>
struct at_impl<ext::boost::mpl::list_tag> {
template <typename Ts, typename N>
static constexpr auto apply(Ts const&, N const&) {
constexpr std::size_t n = N::value;
using T = typename ::boost::mpl::at_c<Ts, n>::type;
return hana::type_c<T>;
}
};
template <>
struct drop_front_impl<ext::boost::mpl::list_tag> {
template <std::size_t n, typename Xs, std::size_t ...i>
static constexpr auto drop_front_helper(Xs const&, std::index_sequence<i...>) {
return boost::mpl::list<
typename boost::mpl::at_c<Xs, n + i>::type...
>{};
}
template <typename Xs, typename N>
static constexpr auto apply(Xs const& xs, N const&) {
constexpr std::size_t n = N::value;
constexpr std::size_t len = decltype(hana::length(xs))::value;
return drop_front_helper<n>(xs,
std::make_index_sequence<(n < len ? len - n : 0)>{});
}
};
template <>
struct is_empty_impl<ext::boost::mpl::list_tag> {
template <typename Xs>
static constexpr auto apply(Xs const&)
{ return typename ::boost::mpl::empty<Xs>::type{}; }
};
//////////////////////////////////////////////////////////////////////////
// Conversion from a Foldable
//////////////////////////////////////////////////////////////////////////
template <typename F>
struct to_impl<ext::boost::mpl::list_tag, F, when<hana::Foldable<F>::value>> {
template <typename Xs>
static constexpr decltype(auto) apply(Xs&& xs) {
auto list_type = hana::unpack(static_cast<Xs&&>(xs),
hana::template_<::boost::mpl::list>);
return typename decltype(list_type)::type{};
}
};
BOOST_HANA_NAMESPACE_END
#endif // !BOOST_HANA_EXT_BOOST_MPL_LIST_HPP
@@ -0,0 +1,185 @@
/*!
@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 <boost/hana/concept/foldable.hpp>
#include <boost/hana/config.hpp>
#include <boost/hana/core/when.hpp>
#include <boost/hana/ext/boost/mpl/integral_c.hpp>
#include <boost/hana/fwd/at.hpp>
#include <boost/hana/fwd/core/to.hpp>
#include <boost/hana/fwd/core/tag_of.hpp>
#include <boost/hana/fwd/drop_front.hpp>
#include <boost/hana/fwd/equal.hpp>
#include <boost/hana/fwd/is_empty.hpp>
#include <boost/hana/fwd/less.hpp>
#include <boost/hana/integral_constant.hpp>
#include <boost/hana/length.hpp>
#include <boost/hana/type.hpp>
#include <boost/hana/unpack.hpp>
#include <boost/mpl/at.hpp>
#include <boost/mpl/empty.hpp>
#include <boost/mpl/equal.hpp>
#include <boost/mpl/sequence_tag.hpp>
#include <boost/mpl/size.hpp>
#include <boost/mpl/vector.hpp>
#include <cstddef>
#include <type_traits>
#include <utility>
#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<ext::boost::mpl::vector_tag>(xs) == mpl::vector<t1, ..., tn>
//! @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 <typename ...T>
struct vector { };
}}
#endif
BOOST_HANA_NAMESPACE_BEGIN
namespace ext { namespace boost { namespace mpl {
using vector_tag = ::boost::mpl::sequence_tag< ::boost::mpl::vector<>>::type;
}}}
template <typename T>
struct tag_of<T, when<
std::is_same<
typename ::boost::mpl::sequence_tag<T>::type,
::boost::mpl::sequence_tag< ::boost::mpl::vector<>>::type
>::value
>> {
using type = ext::boost::mpl::vector_tag;
};
//////////////////////////////////////////////////////////////////////////
// Comparable
//////////////////////////////////////////////////////////////////////////
template <>
struct equal_impl<ext::boost::mpl::vector_tag, ext::boost::mpl::vector_tag> {
template <typename Xs, typename Ys>
static constexpr auto apply(Xs const&, Ys const&) {
return typename ::boost::mpl::equal<Xs, Ys>::type{};
}
};
//////////////////////////////////////////////////////////////////////////
// Foldable
//////////////////////////////////////////////////////////////////////////
template <>
struct length_impl<ext::boost::mpl::vector_tag> {
template <typename Xs>
static constexpr auto apply(Xs const&) {
return hana::size_c< ::boost::mpl::size<Xs>::type::value>;
}
};
//////////////////////////////////////////////////////////////////////////
// Iterable
//////////////////////////////////////////////////////////////////////////
template <>
struct at_impl<ext::boost::mpl::vector_tag> {
template <typename Ts, typename N>
static constexpr auto apply(Ts const&, N const&) {
constexpr std::size_t n = N::value;
using T = typename ::boost::mpl::at_c<Ts, n>::type;
return hana::type_c<T>;
}
};
template <>
struct drop_front_impl<ext::boost::mpl::vector_tag> {
template <std::size_t n, typename Xs, std::size_t ...i>
static constexpr auto drop_front_helper(Xs const&, std::index_sequence<i...>) {
return boost::mpl::vector<
typename boost::mpl::at_c<Xs, n + i>::type...
>{};
}
template <typename Xs, typename N>
static constexpr auto apply(Xs const& xs, N const&) {
constexpr std::size_t n = N::value;
constexpr std::size_t len = decltype(hana::length(xs))::value;
return drop_front_helper<n>(xs,
std::make_index_sequence<(n < len ? len - n : 0)>{});
}
};
template <>
struct is_empty_impl<ext::boost::mpl::vector_tag> {
template <typename xs>
static constexpr auto apply(xs)
{ return typename ::boost::mpl::empty<xs>::type{}; }
};
//////////////////////////////////////////////////////////////////////////
// Conversion from a Foldable
//////////////////////////////////////////////////////////////////////////
template <typename F>
struct to_impl<ext::boost::mpl::vector_tag, F, when<hana::Foldable<F>::value>> {
template <typename Xs>
static constexpr auto apply(Xs const& xs) {
auto vector_type = hana::unpack(xs, hana::template_<boost::mpl::vector>);
return typename decltype(vector_type)::type{};
}
};
BOOST_HANA_NAMESPACE_END
#endif // !BOOST_HANA_EXT_BOOST_MPL_VECTOR_HPP
@@ -0,0 +1,138 @@
/*!
@file
Adapts `boost::tuple` 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_TUPLE_HPP
#define BOOST_HANA_EXT_BOOST_TUPLE_HPP
#include <boost/hana/bool.hpp>
#include <boost/hana/config.hpp>
#include <boost/hana/detail/decay.hpp>
#include <boost/hana/fwd/at.hpp>
#include <boost/hana/fwd/core/make.hpp>
#include <boost/hana/fwd/core/tag_of.hpp>
#include <boost/hana/fwd/drop_front.hpp>
#include <boost/hana/fwd/is_empty.hpp>
#include <boost/hana/fwd/length.hpp>
#include <boost/hana/integral_constant.hpp>
#include <boost/tuple/tuple.hpp>
#include <cstddef>
#include <utility>
#ifdef BOOST_HANA_DOXYGEN_INVOKED
namespace boost {
//! @ingroup group-ext-boost
//! Adapter for `boost::tuple`s.
//!
//!
//! Modeled concepts
//! ----------------
//! A `boost::tuple` is a model of the `Sequence` concept, and all the
//! concepts it refines. That makes it essentially the same as a Hana
//! tuple, although the complexity of some operations might differ from
//! that of Hana's tuple.
//!
//! @include example/ext/boost/tuple.cpp
template <typename ...T>
struct tuple { };
}
#endif
BOOST_HANA_NAMESPACE_BEGIN
namespace ext { namespace boost { struct tuple_tag; }}
template <typename ...Xs>
struct tag_of<boost::tuple<Xs...>> {
using type = ext::boost::tuple_tag;
};
template <typename H, typename T>
struct tag_of<boost::tuples::cons<H, T>> {
using type = ext::boost::tuple_tag;
};
template <>
struct tag_of<boost::tuples::null_type> {
using type = ext::boost::tuple_tag;
};
//////////////////////////////////////////////////////////////////////////
// Iterable
//////////////////////////////////////////////////////////////////////////
template <>
struct at_impl<ext::boost::tuple_tag> {
template <typename Xs, typename N>
static constexpr decltype(auto) apply(Xs&& xs, N const&) {
constexpr std::size_t n = N::value;
return static_cast<Xs&&>(xs).template get<n>();
}
};
template <>
struct drop_front_impl<ext::boost::tuple_tag> {
template <std::size_t n, typename Xs, std::size_t ...i>
static constexpr auto drop_front_helper(Xs&& xs, std::index_sequence<i...>) {
return hana::make<ext::boost::tuple_tag>(
hana::at_c<n + i>(static_cast<Xs&&>(xs))...
);
}
template <typename Xs, typename N>
static constexpr auto apply(Xs&& xs, N const&) {
constexpr std::size_t n = N::value;
constexpr std::size_t len = decltype(hana::length(xs))::value;
return drop_front_helper<n>(static_cast<Xs&&>(xs),
std::make_index_sequence<(n < len ? len - n : 0)>{});
}
};
template <>
struct is_empty_impl<ext::boost::tuple_tag> {
static constexpr auto apply(boost::tuples::null_type const&)
{ return hana::true_c; }
template <typename H, typename T>
static constexpr auto apply(boost::tuples::cons<H, T> const&)
{ return hana::false_c; }
};
//////////////////////////////////////////////////////////////////////////
// Foldable
//////////////////////////////////////////////////////////////////////////
template <>
struct length_impl<ext::boost::tuple_tag> {
template <typename Xs>
static constexpr auto apply(Xs const&) {
return hana::size_c<boost::tuples::length<Xs>::value>;
}
};
//////////////////////////////////////////////////////////////////////////
// Sequence
//////////////////////////////////////////////////////////////////////////
template <>
struct Sequence<ext::boost::tuple_tag> {
static constexpr bool value = true;
};
template <>
struct make_impl<ext::boost::tuple_tag> {
template <typename ...Xs>
static constexpr auto apply(Xs&& ...xs) {
return boost::tuples::tuple<
typename detail::decay<Xs>::type...
>{static_cast<Xs&&>(xs)...};
}
};
BOOST_HANA_NAMESPACE_END
#endif // !BOOST_HANA_EXT_BOOST_TUPLE_HPP