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

codecvt: no conversion for all char-like types of size 1. #2739

Merged
merged 10 commits into from
Jun 2, 2022
Merged
Prev Previous commit
Next Next commit
refactor a bit
fsb4000 committed May 25, 2022

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 73517f628f86157eebcd70208b2cd17329e85d98
30 changes: 23 additions & 7 deletions stl/inc/xlocale
Original file line number Diff line number Diff line change
@@ -651,15 +651,31 @@ protected:
}
};

template <class _Elem, class _Byte>
_INLINE_VAR constexpr bool _Codecvt_do_always_noconv = ((sizeof(_Byte) == 1) && (sizeof(_Elem) == 1) &&
template <class _Elem>
_INLINE_VAR constexpr bool _One_byte_char_like = false;

template <>
_INLINE_VAR constexpr bool _One_byte_char_like<char> = true;

template <>
_INLINE_VAR constexpr bool _One_byte_char_like<signed char> = true;

template <>
_INLINE_VAR constexpr bool _One_byte_char_like<unsigned char> = true;

#ifdef __cpp_lib_byte
(is_integral_v<_Byte> || is_same_v<_Byte, byte>) && //
(is_integral_v<_Elem> || is_same_v<_Elem, byte>) )
#else // ^^ __cpp_lib_byte / !__cpp_lib_byte vv
is_integral_v<_Byte> && is_integral_v<_Elem>)
template <>
_INLINE_VAR constexpr bool _One_byte_char_like<byte> = true;
#endif // __cpp_lib_byte
|| is_same_v<_Byte, _Elem>;

#ifdef __cpp_char8_t
template <>
_INLINE_VAR constexpr bool _One_byte_char_like<char8_t> = true;
#endif // __cpp_char8_t

template <class _Elem, class _Byte>
_INLINE_VAR constexpr bool
_Codecvt_do_always_noconv = is_same_v<_Byte, _Elem> || (_One_byte_char_like<_Elem> && _One_byte_char_like<_Byte>);

template <class _Elem, class _Byte, class _Statype>
class codecvt : public codecvt_base { // facet for converting between _Elem and _Byte sequences