]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/hana/include/boost/hana/insert.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / hana / include / boost / hana / insert.hpp
CommitLineData
7c673cae
FG
1/*!
2@file
3Defines `boost::hana::insert`.
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_INSERT_HPP
11#define BOOST_HANA_INSERT_HPP
12
13#include <boost/hana/fwd/insert.hpp>
14
15#include <boost/hana/append.hpp>
16#include <boost/hana/concat.hpp>
17#include <boost/hana/concept/sequence.hpp>
18#include <boost/hana/config.hpp>
19#include <boost/hana/core/dispatch.hpp>
20#include <boost/hana/drop_front.hpp>
21#include <boost/hana/take_front.hpp>
22
23
24BOOST_HANA_NAMESPACE_BEGIN
25 //! @cond
26 template <typename Set, typename ...Args>
27 constexpr decltype(auto) insert_t::operator()(Set&& set, Args&& ...args) const {
28 return insert_impl<typename hana::tag_of<Set>::type>::apply(
29 static_cast<Set&&>(set),
30 static_cast<Args&&>(args)...
31 );
32 }
33 //! @endcond
34
35 template <typename T, bool condition>
36 struct insert_impl<T, when<condition>> : default_ {
37 template <typename ...Args>
38 static constexpr auto apply(Args&& ...) = delete;
39 };
40
41 template <typename S>
42 struct insert_impl<S, when<Sequence<S>::value>> {
43 template <typename Xs, typename N, typename Element>
44 static constexpr auto apply(Xs&& xs, N const& n, Element&& e) {
45 return hana::concat(hana::append(hana::take_front(xs, n),
46 static_cast<Element&&>(e)),
47 hana::drop_front(xs, n));
48 }
49 };
50BOOST_HANA_NAMESPACE_END
51
52#endif // !BOOST_HANA_INSERT_HPP