3 Forward declares `boost::hana::integral_constant`.
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)
10 #ifndef BOOST_HANA_FWD_INTEGRAL_CONSTANT_HPP
11 #define BOOST_HANA_FWD_INTEGRAL_CONSTANT_HPP
13 #include <boost/hana/config.hpp>
14 #include <boost/hana/detail/integral_constant.hpp>
19 BOOST_HANA_NAMESPACE_BEGIN
20 //! Creates an `integral_constant` holding the given compile-time value.
21 //! @relates hana::integral_constant
23 //! Specifically, `integral_c<T, v>` is a `hana::integral_constant`
24 //! holding the compile-time value `v` of an integral type `T`.
28 //! The type of the value to hold in the `integral_constant`.
29 //! It must be an integral type.
32 //! The integral value to hold in the `integral_constant`.
37 //! @snippet example/integral_constant.cpp integral_c
38 template <typename T, T v>
39 constexpr integral_constant<T, v> integral_c{};
42 //! @relates hana::integral_constant
44 using bool_ = integral_constant<bool, b>;
46 //! @relates hana::integral_constant
48 constexpr bool_<b> bool_c{};
50 //! @relates hana::integral_constant
51 using true_ = bool_<true>;
53 //! @relates hana::integral_constant
54 constexpr auto true_c = bool_c<true>;
56 //! @relates hana::integral_constant
57 using false_ = bool_<false>;
59 //! @relates hana::integral_constant
60 constexpr auto false_c = bool_c<false>;
63 //! @relates hana::integral_constant
65 using char_ = integral_constant<char, c>;
67 //! @relates hana::integral_constant
69 constexpr char_<c> char_c{};
72 //! @relates hana::integral_constant
74 using short_ = integral_constant<short, i>;
76 //! @relates hana::integral_constant
78 constexpr short_<i> short_c{};
81 //! @relates hana::integral_constant
82 template <unsigned short i>
83 using ushort_ = integral_constant<unsigned short, i>;
85 //! @relates hana::integral_constant
86 template <unsigned short i>
87 constexpr ushort_<i> ushort_c{};
90 //! @relates hana::integral_constant
92 using int_ = integral_constant<int, i>;
94 //! @relates hana::integral_constant
96 constexpr int_<i> int_c{};
99 //! @relates hana::integral_constant
100 template <unsigned int i>
101 using uint = integral_constant<unsigned int, i>;
103 //! @relates hana::integral_constant
104 template <unsigned int i>
105 constexpr uint<i> uint_c{};
108 //! @relates hana::integral_constant
110 using long_ = integral_constant<long, i>;
112 //! @relates hana::integral_constant
114 constexpr long_<i> long_c{};
117 //! @relates hana::integral_constant
118 template <unsigned long i>
119 using ulong = integral_constant<unsigned long, i>;
121 //! @relates hana::integral_constant
122 template <unsigned long i>
123 constexpr ulong<i> ulong_c{};
126 //! @relates hana::integral_constant
127 template <long long i>
128 using llong = integral_constant<long long, i>;
130 //! @relates hana::integral_constant
131 template <long long i>
132 constexpr llong<i> llong_c{};
135 //! @relates hana::integral_constant
136 template <unsigned long long i>
137 using ullong = integral_constant<unsigned long long, i>;
139 //! @relates hana::integral_constant
140 template <unsigned long long i>
141 constexpr ullong<i> ullong_c{};
144 //! @relates hana::integral_constant
145 template <std::size_t i>
146 using size_t = integral_constant<std::size_t, i>;
148 //! @relates hana::integral_constant
149 template <std::size_t i>
150 constexpr size_t<i> size_c{};
154 //! Creates a `hana::integral_constant` from a literal.
155 //! @relatesalso boost::hana::integral_constant
157 //! The literal is parsed at compile-time and the result is returned
158 //! as a `llong<...>`.
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>`.
169 //! @snippet example/integral_constant.cpp literals
171 constexpr auto operator"" _c();
173 BOOST_HANA_NAMESPACE_END
175 #endif // !BOOST_HANA_FWD_INTEGRAL_CONSTANT_HPP