From df91243a1deadfbebf52f795f511b4944cd217ba Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sat, 21 Aug 2021 20:28:47 +0300 Subject: [PATCH] Whether wchar_t is signed is implementation-defined --- include/boost/core/lightweight_test.hpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/include/boost/core/lightweight_test.hpp b/include/boost/core/lightweight_test.hpp index 725c247..3b5df89 100644 --- a/include/boost/core/lightweight_test.hpp +++ b/include/boost/core/lightweight_test.hpp @@ -181,7 +181,13 @@ inline const void* test_output_impl(std::nullptr_t) { return nullptr; } inline int test_output_impl( signed char const& v ) { return v; } inline unsigned test_output_impl( unsigned char const& v ) { return v; } -inline unsigned long test_output_impl( wchar_t const& v ) { return v; } +// Whether wchar_t is signed is implementation-defined + +template struct lwt_long_type {}; +template<> struct lwt_long_type { typedef long type; }; +template<> struct lwt_long_type { typedef unsigned long type; }; + +inline lwt_long_type<(static_cast(-1) < static_cast(0))>::type test_output_impl( wchar_t const& v ) { return v; } #if !defined( BOOST_NO_CXX11_CHAR16_T ) inline unsigned long test_output_impl( char16_t const& v ) { return v; }