Skip to content

Commit 0275422

Browse files
committed
Simplify to_big_endian and from_big_endian
1 parent aada2d8 commit 0275422

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

include/msgpack23/msgpack23.h

+3-7
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ namespace msgpack23 {
113113
template<typename T>
114114
concept VariantLike = is_variant_v<T>;
115115

116-
template<typename T, std::enable_if_t<std::is_integral_v<T>, int> = 0>
116+
template<std::integral T>
117117
[[nodiscard]] constexpr T to_big_endian(T const value) noexcept {
118118
if constexpr (std::endian::native == std::endian::little) {
119119
return std::byteswap(value);
@@ -122,13 +122,9 @@ namespace msgpack23 {
122122
}
123123
}
124124

125-
template<typename T, std::enable_if_t<std::is_integral_v<T>, int> = 0>
125+
template<std::integral T>
126126
[[nodiscard]] constexpr T from_big_endian(T const value) noexcept {
127-
if constexpr (std::endian::native == std::endian::little) {
128-
return std::byteswap(value);
129-
} else {
130-
return value;
131-
}
127+
return to_big_endian(value);
132128
}
133129

134130
class Packer {

0 commit comments

Comments
 (0)