]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/hana/include/boost/hana/ext/boost/fusion/list.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / hana / include / boost / hana / ext / boost / fusion / list.hpp
1 /*!
2 @file
3 Adapts `boost::fusion::list` for use with Hana.
4
5 @copyright Louis Dionne 2013-2016
6 Distributed under the Boost Software License, Version 1.0.
7 (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
8 */
9
10 #ifndef BOOST_HANA_EXT_BOOST_FUSION_LIST_HPP
11 #define BOOST_HANA_EXT_BOOST_FUSION_LIST_HPP
12
13 #include <boost/hana/config.hpp>
14 #include <boost/hana/core/when.hpp>
15 #include <boost/hana/ext/boost/fusion/detail/common.hpp>
16 #include <boost/hana/fwd/at.hpp>
17 #include <boost/hana/fwd/core/make.hpp>
18 #include <boost/hana/fwd/core/tag_of.hpp>
19 #include <boost/hana/fwd/drop_front.hpp>
20 #include <boost/hana/fwd/length.hpp>
21
22 #include <boost/fusion/algorithm/transformation/pop_front.hpp>
23 #include <boost/fusion/container/generation/make_list.hpp>
24 #include <boost/fusion/container/list.hpp>
25 #include <boost/fusion/container/list/convert.hpp>
26 #include <boost/fusion/support/tag_of.hpp>
27 #include <boost/version.hpp>
28
29 #include <cstddef>
30 #include <type_traits>
31 #include <utility>
32
33
34 #ifdef BOOST_HANA_DOXYGEN_INVOKED
35 namespace boost { namespace fusion {
36 //! @ingroup group-ext-fusion
37 //! Adapter for Boost.Fusion lists.
38 //!
39 //!
40 //! Modeled concepts
41 //! ----------------
42 //! A Fusion list is a model of the `Sequence` concept, and all the
43 //! concepts it refines. That makes it essentially the same as a Hana
44 //! tuple, although the complexity of some operations might differ from
45 //! that of a tuple.
46 //!
47 //! @include example/ext/boost/fusion/list.cpp
48 template <typename ...T>
49 struct list { };
50 }}
51 #endif
52
53
54 BOOST_HANA_NAMESPACE_BEGIN
55 namespace ext { namespace boost { namespace fusion {
56 struct list_tag;
57 }}}
58
59 template <typename T>
60 struct tag_of<T, when<
61 std::is_same<
62 typename ::boost::fusion::traits::tag_of<T>::type,
63 ::boost::fusion::traits::tag_of<
64 ::boost::fusion::list<>
65 >::type
66 >::value
67 >> {
68 using type = ext::boost::fusion::list_tag;
69 };
70
71 namespace detail {
72 template <>
73 struct is_fusion_sequence<ext::boost::fusion::list_tag> {
74 static constexpr bool value = true;
75 };
76 }
77
78 //////////////////////////////////////////////////////////////////////////
79 // Iterable (the rest is in detail/common.hpp)
80 //////////////////////////////////////////////////////////////////////////
81 template <>
82 struct drop_front_impl<ext::boost::fusion::list_tag> {
83 template <std::size_t n, typename Xs, std::size_t ...i>
84 static constexpr auto drop_front_helper(Xs&& xs, std::index_sequence<i...>) {
85 return hana::make<ext::boost::fusion::list_tag>(
86 hana::at_c<n + i>(static_cast<Xs&&>(xs))...
87 );
88 }
89
90 template <typename Xs, typename N>
91 static constexpr auto apply(Xs&& xs, N const&) {
92 constexpr std::size_t n = N::value;
93 constexpr std::size_t len = decltype(hana::length(xs))::value;
94 return drop_front_helper<n>(static_cast<Xs&&>(xs),
95 std::make_index_sequence<(n < len ? len - n : 0)>{});
96 }
97 };
98
99 //////////////////////////////////////////////////////////////////////////
100 // Sequence
101 //////////////////////////////////////////////////////////////////////////
102 template <>
103 struct make_impl<ext::boost::fusion::list_tag> {
104 template <typename ...Xs>
105 static constexpr auto apply(Xs&& ...xs) {
106 return ::boost::fusion::make_list(static_cast<Xs&&>(xs)...);
107 }
108 };
109 BOOST_HANA_NAMESPACE_END
110
111 #endif // !BOOST_HANA_EXT_BOOST_FUSION_LIST_HPP