From 5614d6fe775d5715dbee23ddcba87b31c95060ca Mon Sep 17 00:00:00 2001 From: Oleksandr Koval Date: Sun, 15 Sep 2024 13:39:11 +0300 Subject: [PATCH] define `byteswap` for single-byte types Fixes #69 --- sbepp/src/sbepp/sbepp.hpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/sbepp/src/sbepp/sbepp.hpp b/sbepp/src/sbepp/sbepp.hpp index 7592b70..5f92344 100644 --- a/sbepp/src/sbepp/sbepp.hpp +++ b/sbepp/src/sbepp/sbepp.hpp @@ -458,11 +458,14 @@ using std::byteswap; #else -// because `if((E == endian::native) || (sizeof(T) == 1))` is not a constexpr-if -// this function has to be declared for single byte types even if it will never -// be used -template -T byteswap(T) noexcept; +// because `if((E == endian::native) || (sizeof(T) == 1))` used in +// `get/set_primitive` is not a constexpr-if, this function has to be declared +// (and defined for MSVC) for single byte types even if it will never be used +template> +constexpr T byteswap(T value) noexcept +{ + return value; +} # if defined(_MSC_VER) && (!defined(__clang__) || defined(__c2__))