forked from boostorg/static_string
Fix constexpr when using libstdc++
This commit is contained in:
@ -146,10 +146,12 @@ defined(__clang__) && \
|
|||||||
#define BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
#define BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// For clang and msvc, constexpr does not work with library
|
// These are for compiler/library configurations
|
||||||
// comparison function objects.
|
// that cannot use the library comparison function
|
||||||
#if (defined(__clang__) && (__clang_major__ < 9)) || \
|
// objects at all in constant expresssions. In these
|
||||||
(defined(_MSVC_LANG) && !defined(BOOST_STATIC_STRING_CPP20))
|
// 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
|
#define BOOST_STATIC_STRING_NO_PTR_COMP_FUNCTIONS
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -165,16 +167,6 @@ defined(__clang__) && \
|
|||||||
#include <string_view>
|
#include <string_view>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __clang__
|
|
||||||
#include <new>
|
|
||||||
#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 boost {
|
||||||
namespace static_string {
|
namespace static_string {
|
||||||
|
|
||||||
|
@ -509,7 +509,7 @@ to_static_string_float_impl(Floating value) noexcept
|
|||||||
{
|
{
|
||||||
// extra one needed for null terminator
|
// extra one needed for null terminator
|
||||||
char buffer[N + 1];
|
char buffer[N + 1];
|
||||||
std::sprintf(buffer, "%f", value);
|
std::sprintf(buffer, "%Lf", value);
|
||||||
// this will not throw
|
// this will not throw
|
||||||
return static_string<N>(buffer);
|
return static_string<N>(buffer);
|
||||||
}
|
}
|
||||||
@ -521,7 +521,7 @@ to_static_wstring_float_impl(Floating value) noexcept
|
|||||||
{
|
{
|
||||||
// extra one needed for null terminator
|
// extra one needed for null terminator
|
||||||
wchar_t buffer[N + 1];
|
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
|
// this will not throw
|
||||||
return static_wstring<N>(buffer);
|
return static_wstring<N>(buffer);
|
||||||
}
|
}
|
||||||
@ -611,6 +611,9 @@ is_inside(
|
|||||||
// while retaining the guarentee that the comparison has a strict total ordering.
|
// 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
|
// 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.
|
// 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_NO_PTR_COMP_FUNCTIONS
|
||||||
#ifdef BOOST_STATIC_STRING_USE_IS_CONST_EVAL
|
#ifdef BOOST_STATIC_STRING_USE_IS_CONST_EVAL
|
||||||
// Our second best option is to use is_constant_evaluated
|
// Our second best option is to use is_constant_evaluated
|
||||||
@ -624,11 +627,12 @@ is_inside(
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
// If library comparison functions don't work, then
|
// If library comparison functions don't work, and
|
||||||
// its almost certain that we can use the builtin
|
// we cannot use is_constant_evaluated, we can use
|
||||||
// comparison operator instead.
|
// the builtin comparison operators instead.
|
||||||
return ptr >= src_first && ptr <= src_last;
|
return ptr >= src_first && ptr <= src_last;
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
// Use the library comparison functions if we can't use
|
// Use the library comparison functions if we can't use
|
||||||
// is_constant_evaluated or if we don't need to.
|
// is_constant_evaluated or if we don't need to.
|
||||||
|
Reference in New Issue
Block a user