]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/hana/include/boost/hana/ext/boost/fusion/vector.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / hana / include / boost / hana / ext / boost / fusion / vector.hpp
CommitLineData
7c673cae
FG
1/*!
2@file
3Adapts `boost::fusion::vector` for use with Hana.
4
5@copyright Louis Dionne 2013-2016
6Distributed 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_VECTOR_HPP
11#define BOOST_HANA_EXT_BOOST_FUSION_VECTOR_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_vector.hpp>
24#include <boost/fusion/container/vector.hpp>
25#include <boost/fusion/container/vector/convert.hpp>
26#include <boost/fusion/support/tag_of.hpp>
27
28#include <cstddef>
29#include <type_traits>
30#include <utility>
31
32
33#ifdef BOOST_HANA_DOXYGEN_INVOKED
34namespace boost { namespace fusion {
35 //! @ingroup group-ext-fusion
36 //! Adapter for Boost.Fusion vectors.
37 //!
38 //!
39 //! Modeled concepts
40 //! ----------------
41 //! A Fusion vector is a model of the `Sequence` concept, and all the
42 //! concepts it refines. That makes it essentially the same as a Hana
43 //! tuple, although the complexity of some operations might differ from
44 //! that of a tuple.
45 //!
46 //! @include example/ext/boost/fusion/vector.cpp
47 template <typename ...T>
48 struct vector { };
49}}
50#endif
51
52
53BOOST_HANA_NAMESPACE_BEGIN
54 namespace ext { namespace boost { namespace fusion {
55 struct vector_tag;
56 }}}
57
58 template <typename T>
59 struct tag_of<T, when<
60 std::is_same<
61 typename ::boost::fusion::traits::tag_of<T>::type,
62 ::boost::fusion::traits::tag_of<
63 ::boost::fusion::vector<>
64 >::type
65 >::value
66 >> {
67 using type = ext::boost::fusion::vector_tag;
68 };
69
70 namespace detail {
71 template <>
72 struct is_fusion_sequence<ext::boost::fusion::vector_tag> {
73 static constexpr bool value = true;
74 };
75 }
76
77 //////////////////////////////////////////////////////////////////////////
78 // Iterable (the rest is in detail/common.hpp)
79 //////////////////////////////////////////////////////////////////////////
80 template <>
81 struct drop_front_impl<ext::boost::fusion::vector_tag> {
82 template <std::size_t n, typename Xs, std::size_t ...i>
83 static constexpr auto drop_front_helper(Xs&& xs, std::index_sequence<i...>) {
84 return hana::make<ext::boost::fusion::vector_tag>(
85 hana::at_c<n + i>(static_cast<Xs&&>(xs))...
86 );
87 }
88
89 template <typename Xs, typename N>
90 static constexpr auto apply(Xs&& xs, N const&) {
91 constexpr std::size_t n = N::value;
92 constexpr std::size_t len = decltype(hana::length(xs))::value;
93 return drop_front_helper<n>(static_cast<Xs&&>(xs),
94 std::make_index_sequence<(n < len ? len - n : 0)>{});
95 }
96 };
97
98 //////////////////////////////////////////////////////////////////////////
99 // Sequence
100 //////////////////////////////////////////////////////////////////////////
101 template <>
102 struct make_impl<ext::boost::fusion::vector_tag> {
103 template <typename ...Xs>
104 static constexpr auto apply(Xs&& ...xs) {
105 return ::boost::fusion::make_vector(static_cast<Xs&&>(xs)...);
106 }
107 };
108BOOST_HANA_NAMESPACE_END
109
110#endif // !BOOST_HANA_EXT_BOOST_FUSION_VECTOR_HPP