diff --git a/include/boost/static_string/config.hpp b/include/boost/static_string/config.hpp index d4e1a5a..16c83d5 100644 --- a/include/boost/static_string/config.hpp +++ b/include/boost/static_string/config.hpp @@ -146,10 +146,12 @@ defined(__clang__) && \ #define BOOST_STATIC_STRING_CPP14_CONSTEXPR #endif -// For clang and msvc, constexpr does not work with library -// comparison function objects. -#if (defined(__clang__) && (__clang_major__ < 9)) || \ -(defined(_MSVC_LANG) && !defined(BOOST_STATIC_STRING_CPP20)) +// These are for compiler/library configurations +// that cannot use the library comparison function +// objects at all in constant expresssions. In these +// cases, we use whatever will make more constexpr work. +#if (defined(__clang__) && defined(__GLIBCXX__) && \ +((__GLIBCXX__ > 20181206) && (__GLIBCXX__ < 20190812))) #define BOOST_STATIC_STRING_NO_PTR_COMP_FUNCTIONS #endif @@ -165,16 +167,6 @@ defined(__clang__) && \ #include #endif -#ifdef __clang__ -#include -#define STRING_VALUE(...) STRING_VALUE__(__VA_ARGS__) -#define STRING_VALUE__(...) #__VA_ARGS__ -#pragma message("STATIC STRING CLANG DEBUG INFO") -#pragma message("LIBSTDCXX OLD: " STRING_VALUE(__GLIBCPP__)) -#pragma message("LIBSTDCXX NEW: " STRING_VALUE(__GLIBCXX__)) -#pragma message("LIBCXX: " STRING_VALUE(_LIBCPP_VERSION)) -#endif - namespace boost { namespace static_string { diff --git a/include/boost/static_string/static_string.hpp b/include/boost/static_string/static_string.hpp index a995a4b..a4b6f4f 100644 --- a/include/boost/static_string/static_string.hpp +++ b/include/boost/static_string/static_string.hpp @@ -509,7 +509,7 @@ to_static_string_float_impl(Floating value) noexcept { // extra one needed for null terminator char buffer[N + 1]; - std::sprintf(buffer, "%f", value); + std::sprintf(buffer, "%Lf", value); // this will not throw return static_string(buffer); } @@ -521,7 +521,7 @@ to_static_wstring_float_impl(Floating value) noexcept { // extra one needed for null terminator wchar_t buffer[N + 1]; - std::swprintf(buffer, N + 1, L"%f", value); + std::swprintf(buffer, N + 1, L"%Lf", value); // this will not throw return static_wstring(buffer); } @@ -611,6 +611,9 @@ is_inside( // while retaining the guarentee that the comparison has a strict total ordering. // We also want this to be fast. Since different compilers have differing levels // of conformance, we will settle for the best option that is available. + // We don't care about this in C++11, since this function would have + // no applications in constant expressions. +#ifdef BOOST_STATIC_STRING_CPP14 #ifdef BOOST_STATIC_STRING_NO_PTR_COMP_FUNCTIONS #ifdef BOOST_STATIC_STRING_USE_IS_CONST_EVAL // Our second best option is to use is_constant_evaluated @@ -624,11 +627,12 @@ is_inside( return false; } #else - // If library comparison functions don't work, then - // its almost certain that we can use the builtin - // comparison operator instead. + // If library comparison functions don't work, and + // we cannot use is_constant_evaluated, we can use + // the builtin comparison operators instead. return ptr >= src_first && ptr <= src_last; #endif +#endif #endif // Use the library comparison functions if we can't use // is_constant_evaluated or if we don't need to.