3 Defines `boost::hana::lift`.
5 @copyright Louis Dionne 2013-2017
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)
10 #ifndef BOOST_HANA_LIFT_HPP
11 #define BOOST_HANA_LIFT_HPP
13 #include <boost/hana/fwd/lift.hpp>
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>
22 BOOST_HANA_NAMESPACE_BEGIN
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");
31 constexpr auto operator()(X&& x) const {
32 using Lift = BOOST_HANA_DISPATCH_IF(lift_impl<A>,
33 hana::Applicative<A>::value
36 return Lift::apply(static_cast<X&&>(x));
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;
47 struct lift_impl<S, when<Sequence<S>::value>> {
49 static constexpr decltype(auto) apply(X&& x)
50 { return hana::make<S>(static_cast<X&&>(x)); }
52 BOOST_HANA_NAMESPACE_END
54 #endif // !BOOST_HANA_LIFT_HPP