diff options
author | Roland Reichwein <mail@reichwein.it> | 2021-12-26 19:20:56 +0100 |
---|---|---|
committer | Roland Reichwein <mail@reichwein.it> | 2021-12-26 19:20:56 +0100 |
commit | fcdf5b3f2308555f5c1a5b2585ee2947855e1ca9 (patch) | |
tree | 3965a5c3780ab84273f40c3d2123d47a5f4b313d /src/recode.cpp | |
parent | e0e5623b46fdaa0988faa76af506d5bc1035ee42 (diff) |
Fixes for MSVC
Diffstat (limited to 'src/recode.cpp')
-rw-r--r-- | src/recode.cpp | 23 |
1 files changed, 5 insertions, 18 deletions
diff --git a/src/recode.cpp b/src/recode.cpp index beb133f..2b8f7b2 100644 --- a/src/recode.cpp +++ b/src/recode.cpp @@ -60,27 +60,14 @@ std::string get_id() return get_id(std::string{typeid(From).name()}, typeid(To).name()); } -// workaround for broken boost::endian::endian_reverse_inplace for C++20 in boost 1.74 -template<typename T> -void reverse_endian_inplace(T& c) -{ - size_t size{sizeof(T)}; - uint8_t* p{reinterpret_cast<uint8_t*>(&c)}; - for (int i = 0; i < size / 2; i++) { - std::swap(p[i], p[size - 1 - i]); - } -} - template<typename T> void reverse_endian(std::basic_string<T>& s) { - std::for_each(s.begin(), s.end(), [](T& c){ -#if BOOST_VERSION > 107700 - boost::endian::endian_reverse_inplace(c); -#else - reverse_endian_inplace(c); -#endif - }); + if constexpr (sizeof(T) > 1) { // speedup and prevent broken boost 1.78 char8_t traits + std::for_each(s.begin(), s.end(), [](T& c) { + boost::endian::endian_reverse_inplace(c); + }); + } } std::unordered_map<std::string, std::function<std::string(const std::string&, bool, bool)>> convert_map {}; |