1 /*! 2 @file 3 Forward declares `boost::hana::integral_constant`. 4 5 @copyright Louis Dionne 2013-2017 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 */ 9 10 #ifndef BOOST_HANA_FWD_INTEGRAL_CONSTANT_HPP 11 #define BOOST_HANA_FWD_INTEGRAL_CONSTANT_HPP 12 13 #include <boost/hana/config.hpp> 14 #include <boost/hana/detail/integral_constant.hpp> 15 16 #include <cstddef> 17 18 19 BOOST_HANA_NAMESPACE_BEGIN 20 //! Creates an `integral_constant` holding the given compile-time value. 21 //! @relates hana::integral_constant 22 //! 23 //! Specifically, `integral_c<T, v>` is a `hana::integral_constant` 24 //! holding the compile-time value `v` of an integral type `T`. 25 //! 26 //! 27 //! @tparam T 28 //! The type of the value to hold in the `integral_constant`. 29 //! It must be an integral type. 30 //! 31 //! @tparam v 32 //! The integral value to hold in the `integral_constant`. 33 //! 34 //! 35 //! Example 36 //! ------- 37 //! @snippet example/integral_constant.cpp integral_c 38 template <typename T, T v> 39 constexpr integral_constant<T, v> integral_c{}; 40 41 42 //! @relates hana::integral_constant 43 template <bool b> 44 using bool_ = integral_constant<bool, b>; 45 46 //! @relates hana::integral_constant 47 template <bool b> 48 constexpr bool_<b> bool_c{}; 49 50 //! @relates hana::integral_constant 51 using true_ = bool_<true>; 52 53 //! @relates hana::integral_constant 54 constexpr auto true_c = bool_c<true>; 55 56 //! @relates hana::integral_constant 57 using false_ = bool_<false>; 58 59 //! @relates hana::integral_constant 60 constexpr auto false_c = bool_c<false>; 61 62 63 //! @relates hana::integral_constant 64 template <char c> 65 using char_ = integral_constant<char, c>; 66 67 //! @relates hana::integral_constant 68 template <char c> 69 constexpr char_<c> char_c{}; 70 71 72 //! @relates hana::integral_constant 73 template <short i> 74 using short_ = integral_constant<short, i>; 75 76 //! @relates hana::integral_constant 77 template <short i> 78 constexpr short_<i> short_c{}; 79 80 81 //! @relates hana::integral_constant 82 template <unsigned short i> 83 using ushort_ = integral_constant<unsigned short, i>; 84 85 //! @relates hana::integral_constant 86 template <unsigned short i> 87 constexpr ushort_<i> ushort_c{}; 88 89 90 //! @relates hana::integral_constant 91 template <int i> 92 using int_ = integral_constant<int, i>; 93 94 //! @relates hana::integral_constant 95 template <int i> 96 constexpr int_<i> int_c{}; 97 98 99 //! @relates hana::integral_constant 100 template <unsigned int i> 101 using uint = integral_constant<unsigned int, i>; 102 103 //! @relates hana::integral_constant 104 template <unsigned int i> 105 constexpr uint<i> uint_c{}; 106 107 108 //! @relates hana::integral_constant 109 template <long i> 110 using long_ = integral_constant<long, i>; 111 112 //! @relates hana::integral_constant 113 template <long i> 114 constexpr long_<i> long_c{}; 115 116 117 //! @relates hana::integral_constant 118 template <unsigned long i> 119 using ulong = integral_constant<unsigned long, i>; 120 121 //! @relates hana::integral_constant 122 template <unsigned long i> 123 constexpr ulong<i> ulong_c{}; 124 125 126 //! @relates hana::integral_constant 127 template <long long i> 128 using llong = integral_constant<long long, i>; 129 130 //! @relates hana::integral_constant 131 template <long long i> 132 constexpr llong<i> llong_c{}; 133 134 135 //! @relates hana::integral_constant 136 template <unsigned long long i> 137 using ullong = integral_constant<unsigned long long, i>; 138 139 //! @relates hana::integral_constant 140 template <unsigned long long i> 141 constexpr ullong<i> ullong_c{}; 142 143 144 //! @relates hana::integral_constant 145 template <std::size_t i> 146 using size_t = integral_constant<std::size_t, i>; 147 148 //! @relates hana::integral_constant 149 template <std::size_t i> 150 constexpr size_t<i> size_c{}; 151 152 153 namespace literals { 154 //! Creates a `hana::integral_constant` from a literal. 155 //! @relatesalso boost::hana::integral_constant 156 //! 157 //! The literal is parsed at compile-time and the result is returned 158 //! as a `llong<...>`. 159 //! 160 //! @note 161 //! We use `llong<...>` instead of `ullong<...>` because using an 162 //! unsigned type leads to unexpected behavior when doing stuff like 163 //! `-1_c`. If we used an unsigned type, `-1_c` would be something 164 //! like `ullong<-1>` which is actually `ullong<something huge>`. 165 //! 166 //! 167 //! Example 168 //! ------- 169 //! @snippet example/integral_constant.cpp literals 170 template <char ...c> 171 constexpr auto operator"" _c(); 172 } 173 BOOST_HANA_NAMESPACE_END 174 175 #endif // !BOOST_HANA_FWD_INTEGRAL_CONSTANT_HPP 176