File indexing completed on 2025-01-18 09:37:57
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef BOOST_HANA_EXT_STD_INTEGRAL_CONSTANT_HPP
0011 #define BOOST_HANA_EXT_STD_INTEGRAL_CONSTANT_HPP
0012
0013 #include <boost/hana/concept/integral_constant.hpp>
0014 #include <boost/hana/config.hpp>
0015 #include <boost/hana/core/when.hpp>
0016 #include <boost/hana/fwd/core/to.hpp>
0017 #include <boost/hana/fwd/core/tag_of.hpp>
0018 #include <boost/hana/fwd/integral_constant.hpp>
0019
0020 #include <type_traits>
0021
0022
0023 #ifdef BOOST_HANA_DOXYGEN_INVOKED
0024 namespace std {
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036 template <typename T, T v>
0037 struct integral_constant { };
0038 }
0039 #endif
0040
0041
0042 namespace boost { namespace hana {
0043 namespace ext { namespace std {
0044 template <typename T>
0045 struct integral_constant_tag { using value_type = T; };
0046 }}
0047
0048 namespace detail {
0049 template <typename T, T v>
0050 constexpr bool
0051 is_std_integral_constant(std::integral_constant<T, v>*)
0052 { return true; }
0053
0054 constexpr bool is_std_integral_constant(...)
0055 { return false; }
0056
0057
0058 template <typename T, T v>
0059 constexpr bool
0060 is_hana_integral_constant(hana::integral_constant<T, v>*)
0061 { return true; }
0062
0063 constexpr bool is_hana_integral_constant(...)
0064 { return false; }
0065 }
0066
0067 template <typename T>
0068 struct tag_of<T, when<
0069 detail::is_std_integral_constant((T*)0) &&
0070 !detail::is_hana_integral_constant((T*)0)
0071 >> {
0072 using type = ext::std::integral_constant_tag<
0073 typename hana::tag_of<typename T::value_type>::type
0074 >;
0075 };
0076
0077
0078
0079
0080 template <typename T>
0081 struct IntegralConstant<ext::std::integral_constant_tag<T>> {
0082 static constexpr bool value = true;
0083 };
0084
0085 template <typename T, typename C>
0086 struct to_impl<ext::std::integral_constant_tag<T>, C, when<
0087 hana::IntegralConstant<C>::value
0088 >> : embedding<is_embedded<typename C::value_type, T>::value> {
0089 template <typename N>
0090 static constexpr auto apply(N const&) {
0091 return std::integral_constant<T, N::value>{};
0092 }
0093 };
0094 }}
0095
0096 #endif