]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/hana/include/boost/hana/lift.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / hana / include / boost / hana / lift.hpp
1 /*!
2 @file
3 Defines `boost::hana::lift`.
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_LIFT_HPP
11 #define BOOST_HANA_LIFT_HPP
12
13 #include <boost/hana/fwd/lift.hpp>
14
15 #include <boost/hana/concept/applicative.hpp>
16 #include <boost/hana/concept/sequence.hpp>
17 #include <boost/hana/config.hpp>
18 #include <boost/hana/core/dispatch.hpp>
19 #include <boost/hana/core/make.hpp>
20
21
22 BOOST_HANA_NAMESPACE_BEGIN
23 template <typename A>
24 struct lift_t {
25 #ifndef BOOST_HANA_CONFIG_DISABLE_CONCEPT_CHECKS
26 static_assert(hana::Applicative<A>::value,
27 "hana::lift<A> requires 'A' to be an Applicative");
28 #endif
29
30 template <typename X>
31 constexpr auto operator()(X&& x) const {
32 using Lift = BOOST_HANA_DISPATCH_IF(lift_impl<A>,
33 hana::Applicative<A>::value
34 );
35
36 return Lift::apply(static_cast<X&&>(x));
37 }
38 };
39
40 template <typename A, bool condition>
41 struct lift_impl<A, when<condition>> : default_ {
42 template <typename ...Args>
43 static constexpr auto apply(Args&& ...args) = delete;
44 };
45
46 template <typename S>
47 struct lift_impl<S, when<Sequence<S>::value>> {
48 template <typename X>
49 static constexpr decltype(auto) apply(X&& x)
50 { return hana::make<S>(static_cast<X&&>(x)); }
51 };
52 BOOST_HANA_NAMESPACE_END
53
54 #endif // !BOOST_HANA_LIFT_HPP