1/*!
2@file
3Defines `boost::hana::value`.
4
5Copyright Louis Dionne 2013-2022
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_VALUE_HPP
11#define BOOST_HANA_VALUE_HPP
12
13#include <boost/hana/fwd/value.hpp>
14
15#include <boost/hana/concept/constant.hpp>
16#include <boost/hana/concept/integral_constant.hpp>
17#include <boost/hana/config.hpp>
18#include <boost/hana/core/dispatch.hpp>
19
20#include <type_traits>
21
22
23namespace boost { namespace hana {
24 template <typename C, bool condition>
25 struct value_impl<C, when<condition>> : default_ {
26 template <typename ...Args>
27 static constexpr auto apply(Args&& ...args) = delete;
28 };
29
30 template <typename T>
31 constexpr decltype(auto) value() {
32 using RawT = typename std::remove_cv<
33 typename std::remove_reference<T>::type
34 >::type;
35 using C = typename hana::tag_of<RawT>::type;
36 using Value = BOOST_HANA_DISPATCH_IF(
37 value_impl<C>, hana::Constant<C>::value
38 );
39
40 #ifndef BOOST_HANA_CONFIG_DISABLE_CONCEPT_CHECKS
41 static_assert(hana::Constant<C>::value,
42 "hana::value<T>() requires 'T' to be a Constant");
43 #endif
44
45 return Value::template apply<RawT>();
46 }
47
48 template <typename I>
49 struct value_impl<I, when<hana::IntegralConstant<I>::value>> {
50 template <typename C>
51 static constexpr auto apply()
52 { return C::value; }
53 };
54}} // end namespace boost::hana
55
56#endif // !BOOST_HANA_VALUE_HPP
57

source code of boost/libs/hana/include/boost/hana/value.hpp