Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:38:03

0001 /*!
0002 @file
0003 Defines `boost::hana::lift`.
0004 
0005 Copyright Louis Dionne 2013-2022
0006 Distributed under the Boost Software License, Version 1.0.
0007 (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
0008  */
0009 
0010 #ifndef BOOST_HANA_LIFT_HPP
0011 #define BOOST_HANA_LIFT_HPP
0012 
0013 #include <boost/hana/fwd/lift.hpp>
0014 
0015 #include <boost/hana/concept/applicative.hpp>
0016 #include <boost/hana/concept/sequence.hpp>
0017 #include <boost/hana/config.hpp>
0018 #include <boost/hana/core/dispatch.hpp>
0019 #include <boost/hana/core/make.hpp>
0020 
0021 
0022 namespace boost { namespace hana {
0023     //! @cond
0024     template <typename A>
0025     template <typename X>
0026     constexpr auto lift_t<A>::operator()(X&& x) const {
0027     #ifndef BOOST_HANA_CONFIG_DISABLE_CONCEPT_CHECKS
0028         static_assert(hana::Applicative<A>::value,
0029         "hana::lift<A> requires 'A' to be an Applicative");
0030     #endif
0031 
0032         using Lift = BOOST_HANA_DISPATCH_IF(lift_impl<A>,
0033             hana::Applicative<A>::value
0034         );
0035 
0036         return Lift::apply(static_cast<X&&>(x));
0037     }
0038     //! @endcond
0039 
0040     template <typename A, bool condition>
0041     struct lift_impl<A, when<condition>> : default_ {
0042         template <typename ...Args>
0043         static constexpr auto apply(Args&& ...args) = delete;
0044     };
0045 
0046     template <typename S>
0047     struct lift_impl<S, when<Sequence<S>::value>> {
0048         template <typename X>
0049         static constexpr decltype(auto) apply(X&& x)
0050         { return hana::make<S>(static_cast<X&&>(x)); }
0051     };
0052 }} // end namespace boost::hana
0053 
0054 #endif // !BOOST_HANA_LIFT_HPP