]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/boost/hana/lift.hpp
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / boost / boost / hana / lift.hpp
CommitLineData
7c673cae
FG
1/*!
2@file
3Defines `boost::hana::lift`.
4
b32b8144 5@copyright Louis Dionne 2013-2017
7c673cae
FG
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_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
1e59de90 22namespace boost { namespace hana {
92f5a8d4 23 //! @cond
7c673cae 24 template <typename A>
92f5a8d4
TL
25 template <typename X>
26 constexpr auto lift_t<A>::operator()(X&& x) const {
7c673cae
FG
27 #ifndef BOOST_HANA_CONFIG_DISABLE_CONCEPT_CHECKS
28 static_assert(hana::Applicative<A>::value,
29 "hana::lift<A> requires 'A' to be an Applicative");
30 #endif
31
92f5a8d4
TL
32 using Lift = BOOST_HANA_DISPATCH_IF(lift_impl<A>,
33 hana::Applicative<A>::value
34 );
7c673cae 35
92f5a8d4
TL
36 return Lift::apply(static_cast<X&&>(x));
37 }
38 //! @endcond
7c673cae
FG
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 };
1e59de90 52}} // end namespace boost::hana
7c673cae
FG
53
54#endif // !BOOST_HANA_LIFT_HPP