From 01146c95588a4b98249101f98f09ec29027a79b5 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Tue, 19 Mar 2019 01:06:53 +0200 Subject: [PATCH] Add char and char16_t overloads of endian_reverse --- include/boost/endian/conversion.hpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/include/boost/endian/conversion.hpp b/include/boost/endian/conversion.hpp index 9da4225..a316a3d 100644 --- a/include/boost/endian/conversion.hpp +++ b/include/boost/endian/conversion.hpp @@ -282,6 +282,20 @@ namespace endian # endif } + // overloads for char and char16_t, which otherwise use int32_t + + inline char endian_reverse(char x) BOOST_NOEXCEPT + { + return static_cast( endian_reverse( static_cast(x) ) ); + } + +#if !defined(BOOST_NO_CXX11_CHAR16_T) + inline char16_t endian_reverse(char16_t x) BOOST_NOEXCEPT + { + return static_cast( endian_reverse( static_cast(x) ) ); + } +#endif + template inline EndianReversible big_to_native(EndianReversible x) BOOST_NOEXCEPT {