Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

define byteswap for single-byte types #70

Merged
merged 1 commit into from
Sep 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions sbepp/src/sbepp/sbepp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<typename T>
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<typename T, typename = enable_if_t<sizeof(T) == 1>>
constexpr T byteswap(T value) noexcept
{
return value;
}

# if defined(_MSC_VER) && (!defined(__clang__) || defined(__c2__))

Expand Down