Back to home page

EIC code displayed by LXR

 
 

    


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

0001 /*!
0002 @file
0003 Defines `boost::hana::value`.
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_VALUE_HPP
0011 #define BOOST_HANA_VALUE_HPP
0012 
0013 #include <boost/hana/fwd/value.hpp>
0014 
0015 #include <boost/hana/concept/constant.hpp>
0016 #include <boost/hana/concept/integral_constant.hpp>
0017 #include <boost/hana/config.hpp>
0018 #include <boost/hana/core/dispatch.hpp>
0019 
0020 #include <type_traits>
0021 
0022 
0023 namespace boost { namespace hana {
0024     template <typename C, bool condition>
0025     struct value_impl<C, when<condition>> : default_ {
0026         template <typename ...Args>
0027         static constexpr auto apply(Args&& ...args) = delete;
0028     };
0029 
0030     template <typename T>
0031     constexpr decltype(auto) value() {
0032         using RawT = typename std::remove_cv<
0033             typename std::remove_reference<T>::type
0034         >::type;
0035         using C = typename hana::tag_of<RawT>::type;
0036         using Value = BOOST_HANA_DISPATCH_IF(
0037             value_impl<C>, hana::Constant<C>::value
0038         );
0039 
0040     #ifndef BOOST_HANA_CONFIG_DISABLE_CONCEPT_CHECKS
0041         static_assert(hana::Constant<C>::value,
0042         "hana::value<T>() requires 'T' to be a Constant");
0043     #endif
0044 
0045         return Value::template apply<RawT>();
0046     }
0047 
0048     template <typename I>
0049     struct value_impl<I, when<hana::IntegralConstant<I>::value>> {
0050         template <typename C>
0051         static constexpr auto apply()
0052         { return C::value; }
0053     };
0054 }} // end namespace boost::hana
0055 
0056 #endif // !BOOST_HANA_VALUE_HPP