Adding inline to all byte-related functions for MSVC 2013.

This commit is contained in:
Neil MacIntosh 2016-09-14 11:41:24 -07:00 committed by GitHub
commit 8361aae39e

View File

@ -45,25 +45,25 @@ enum class byte : unsigned char
}; };
template <class IntegerType, class = std::enable_if_t<std::is_integral<IntegerType>::value>> template <class IntegerType, class = std::enable_if_t<std::is_integral<IntegerType>::value>>
constexpr byte& operator<<=(byte& b, IntegerType shift) noexcept inline constexpr byte& operator<<=(byte& b, IntegerType shift) noexcept
{ {
return b = byte(static_cast<unsigned char>(b) << shift); return b = byte(static_cast<unsigned char>(b) << shift);
} }
template <class IntegerType, class = std::enable_if_t<std::is_integral<IntegerType>::value>> template <class IntegerType, class = std::enable_if_t<std::is_integral<IntegerType>::value>>
constexpr byte operator<<(byte b, IntegerType shift) noexcept inline constexpr byte operator<<(byte b, IntegerType shift) noexcept
{ {
return byte(static_cast<unsigned char>(b) << shift); return byte(static_cast<unsigned char>(b) << shift);
} }
template <class IntegerType, class = std::enable_if_t<std::is_integral<IntegerType>::value>> template <class IntegerType, class = std::enable_if_t<std::is_integral<IntegerType>::value>>
constexpr byte& operator>>=(byte& b, IntegerType shift) noexcept inline constexpr byte& operator>>=(byte& b, IntegerType shift) noexcept
{ {
return b = byte(static_cast<unsigned char>(b) >> shift); return b = byte(static_cast<unsigned char>(b) >> shift);
} }
template <class IntegerType, class = std::enable_if_t<std::is_integral<IntegerType>::value>> template <class IntegerType, class = std::enable_if_t<std::is_integral<IntegerType>::value>>
constexpr byte operator>>(byte b, IntegerType shift) noexcept inline constexpr byte operator>>(byte b, IntegerType shift) noexcept
{ {
return byte(static_cast<unsigned char>(b) >> shift); return byte(static_cast<unsigned char>(b) >> shift);
} }
@ -101,13 +101,13 @@ inline constexpr byte operator^(byte l, byte r) noexcept
inline constexpr byte operator~(byte b) noexcept { return byte(~static_cast<unsigned char>(b)); } inline constexpr byte operator~(byte b) noexcept { return byte(~static_cast<unsigned char>(b)); }
template <class IntegerType, class = std::enable_if_t<std::is_integral<IntegerType>::value>> template <class IntegerType, class = std::enable_if_t<std::is_integral<IntegerType>::value>>
constexpr IntegerType to_integer(byte b) noexcept inline constexpr IntegerType to_integer(byte b) noexcept
{ {
return {b}; return {b};
} }
template<bool E, typename T> template<bool E, typename T>
constexpr byte to_byte_impl(T t) noexcept inline constexpr byte to_byte_impl(T t) noexcept
{ {
static_assert( static_assert(
E, E,
@ -117,19 +117,19 @@ constexpr byte to_byte_impl(T t) noexcept
return static_cast<byte>(t); return static_cast<byte>(t);
} }
template<> template<>
constexpr byte to_byte_impl<true, unsigned char>(unsigned char t) noexcept inline constexpr byte to_byte_impl<true, unsigned char>(unsigned char t) noexcept
{ {
return byte(t); return byte(t);
} }
template<typename T> template<typename T>
constexpr byte to_byte(T t) noexcept inline constexpr byte to_byte(T t) noexcept
{ {
return to_byte_impl<std::is_same<T, unsigned char>::value, T>(t); return to_byte_impl<std::is_same<T, unsigned char>::value, T>(t);
} }
template <int I> template <int I>
constexpr byte to_byte() noexcept inline constexpr byte to_byte() noexcept
{ {
static_assert(I >= 0 && I <= 255, "gsl::byte only has 8 bits of storage, values must be in range 0-255"); static_assert(I >= 0 && I <= 255, "gsl::byte only has 8 bits of storage, values must be in range 0-255");
return static_cast<byte>(I); return static_cast<byte>(I);