File tree Expand file tree Collapse file tree 1 file changed +11
-4
lines changed
Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Original file line number Diff line number Diff line change 7474#define byte_may_alias
7575#endif // defined __clang__ || defined __GNUC__
7676
77+ #if GSL_USE_STD_BYTE
78+ #define BYTE_TYPE std::byte
79+ #else // !GSL_USE_STD_BYTE
80+ #define BYTE_TYPE byte
81+ #endif // GSL_USE_STD_BYTE
82+
7783#if GSL_USE_STD_BYTE
7884#include <cstddef>
7985#endif
@@ -158,23 +164,24 @@ constexpr IntegerType to_integer(byte b) noexcept
158164
159165#endif // GSL_USE_STD_BYTE
160166
167+
161168template <typename T>
162169// NOTE: need suppression since c++14 does not allow "return {t}"
163170// GSL_SUPPRESS(type.4) // NO-FORMAT: attribute // TODO: suppression does not work
164- constexpr byte to_byte(T t) noexcept
171+ constexpr BYTE_TYPE to_byte(T t) noexcept
165172{
166173 static_assert(std::is_same<T, unsigned char>::value,
167174 "gsl::to_byte(t) must be provided an unsigned char, otherwise data loss may occur. "
168175 "If you are calling to_byte with an integer constant use: gsl::to_byte<t>() version.");
169- return byte (t);
176+ return BYTE_TYPE (t);
170177}
171178
172179template <int I>
173- constexpr byte to_byte() noexcept
180+ constexpr BYTE_TYPE to_byte() noexcept
174181{
175182 static_assert(I >= 0 && I <= 255,
176183 "gsl::byte only has 8 bits of storage, values must be in range 0-255");
177- return static_cast<byte >(I);
184+ return static_cast<BYTE_TYPE >(I);
178185}
179186
180187} // namespace gsl
You can’t perform that action at this time.
0 commit comments