Project revived from Feb2017
[EroSomnia.git] / deps / boost_1_63_0 / boost / hana / value.hpp
blobfd5b5c402927137704c17f5a7643e66c0cfc74da
1 /*!
2 @file
3 Defines `boost::hana::value`.
5 @copyright Louis Dionne 2013-2016
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)
8 */
10 #ifndef BOOST_HANA_VALUE_HPP
11 #define BOOST_HANA_VALUE_HPP
13 #include <boost/hana/fwd/value.hpp>
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>
20 #include <type_traits>
23 BOOST_HANA_NAMESPACE_BEGIN
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;
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
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
45 return Value::template apply<RawT>();
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; }
54 BOOST_HANA_NAMESPACE_END
56 #endif // !BOOST_HANA_VALUE_HPP