forked from boostorg/static_string
Remove warnings
This commit is contained in:
@ -41,13 +41,29 @@
|
|||||||
#define BOOST_STATIC_STRING_IS_CONST_EVAL __builtin_is_constant_evaluated()
|
#define BOOST_STATIC_STRING_IS_CONST_EVAL __builtin_is_constant_evaluated()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Can we use [[nodiscard]]?
|
// This is borrowed from Boost.JSON
|
||||||
#ifdef __has_attribute
|
// https://github.com/vinniefalco/json/blob/develop/include/boost/json/detail/config.hpp
|
||||||
#if __has_attribute(nodiscard)
|
#if defined(_MSC_VER)
|
||||||
#define BOOST_STATIC_STRING_NODISCARD [[nodiscard]]
|
#define BOOST_STATIC_STRING_NORETURN __declspec(noreturn)
|
||||||
#else
|
#elif defined(__GNUC__)
|
||||||
#define BOOST_STATIC_STRING_NODISCARD
|
#define BOOST_STATIC_STRING_NORETURN __attribute__ ((__noreturn__))
|
||||||
|
#elif defined(__has_attribute) && defined(__SUNPRO_CC) && (__SUNPRO_CC > 0x5130)
|
||||||
|
#if __has_attribute(noreturn)
|
||||||
|
#define BOOST_STATIC_STRING_NORETURN [[noreturn]]
|
||||||
#endif
|
#endif
|
||||||
|
#elif defined(__has_cpp_attribute)
|
||||||
|
#if __has_cpp_attribute(noreturn)
|
||||||
|
#define BOOST_STATIC_STRING_NORETURN [[noreturn]]
|
||||||
|
#endif
|
||||||
|
#else
|
||||||
|
#define BOOST_STATIC_STRING_NORETURN
|
||||||
|
#define BOOST_STATIC_STRING_NO_NORETURN
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Can we use [[nodiscard]]?
|
||||||
|
// KRYSTIAN TODO: these checks need to be improved
|
||||||
|
#if defined(__has_attribute) && __has_attribute(nodiscard)
|
||||||
|
#define BOOST_STATIC_STRING_NODISCARD [[nodiscard]]
|
||||||
#else
|
#else
|
||||||
#define BOOST_STATIC_STRING_NODISCARD
|
#define BOOST_STATIC_STRING_NODISCARD
|
||||||
#endif
|
#endif
|
||||||
|
@ -464,7 +464,7 @@ to_static_wstring_int_impl(Integer value) noexcept
|
|||||||
|
|
||||||
BOOST_STATIC_STRING_CPP11_CONSTEXPR
|
BOOST_STATIC_STRING_CPP11_CONSTEXPR
|
||||||
inline
|
inline
|
||||||
std::size_t
|
int
|
||||||
count_digits(std::size_t value)
|
count_digits(std::size_t value)
|
||||||
{
|
{
|
||||||
return value < 10 ? 1 : count_digits(value / 10) + 1;
|
return value < 10 ? 1 : count_digits(value / 10) + 1;
|
||||||
@ -484,7 +484,7 @@ to_static_string_float_impl(double value) noexcept
|
|||||||
// the + 4 is for the decimal, 'e',
|
// the + 4 is for the decimal, 'e',
|
||||||
// its sign, and the sign of the integral portion
|
// its sign, and the sign of the integral portion
|
||||||
const int reserved_count =
|
const int reserved_count =
|
||||||
(std::max)(std::size_t(2), count_digits(
|
(std::max)(2, count_digits(
|
||||||
std::numeric_limits<double>::max_exponent10)) + 4;
|
std::numeric_limits<double>::max_exponent10)) + 4;
|
||||||
const int precision = N > reserved_count ? N - reserved_count : 0;
|
const int precision = N > reserved_count ? N - reserved_count : 0;
|
||||||
// switch to scientific notation
|
// switch to scientific notation
|
||||||
@ -510,7 +510,7 @@ to_static_string_float_impl(long double value) noexcept
|
|||||||
// the + 4 is for the decimal, 'e',
|
// the + 4 is for the decimal, 'e',
|
||||||
// its sign, and the sign of the integral portion
|
// its sign, and the sign of the integral portion
|
||||||
const int reserved_count =
|
const int reserved_count =
|
||||||
(std::max)(std::size_t(2), count_digits(
|
(std::max)(2, count_digits(
|
||||||
std::numeric_limits<long double>::max_exponent10)) + 4;
|
std::numeric_limits<long double>::max_exponent10)) + 4;
|
||||||
const int precision = N > reserved_count ? N - reserved_count : 0;
|
const int precision = N > reserved_count ? N - reserved_count : 0;
|
||||||
// switch to scientific notation
|
// switch to scientific notation
|
||||||
@ -545,7 +545,7 @@ to_static_wstring_float_impl(double value) noexcept
|
|||||||
// the + 4 is for the decimal, 'e',
|
// the + 4 is for the decimal, 'e',
|
||||||
// its sign, and the sign of the integral portion
|
// its sign, and the sign of the integral portion
|
||||||
const int reserved_count =
|
const int reserved_count =
|
||||||
(std::max)(std::size_t(2), count_digits(
|
(std::max)(2, count_digits(
|
||||||
std::numeric_limits<double>::max_exponent10)) + 4;
|
std::numeric_limits<double>::max_exponent10)) + 4;
|
||||||
const int precision = N > reserved_count ? N - reserved_count : 0;
|
const int precision = N > reserved_count ? N - reserved_count : 0;
|
||||||
// switch to scientific notation
|
// switch to scientific notation
|
||||||
@ -580,7 +580,7 @@ to_static_wstring_float_impl(long double value) noexcept
|
|||||||
// the + 4 is for the decimal, 'e',
|
// the + 4 is for the decimal, 'e',
|
||||||
// its sign, and the sign of the integral portion
|
// its sign, and the sign of the integral portion
|
||||||
const int reserved_count =
|
const int reserved_count =
|
||||||
(std::max)(std::size_t(2), count_digits(
|
(std::max)(2, count_digits(
|
||||||
std::numeric_limits<long double>::max_exponent10)) + 4;
|
std::numeric_limits<long double>::max_exponent10)) + 4;
|
||||||
const int precision = N > reserved_count ? N - reserved_count : 0;
|
const int precision = N > reserved_count ? N - reserved_count : 0;
|
||||||
// switch to scientific notation
|
// switch to scientific notation
|
||||||
@ -4215,12 +4215,16 @@ private:
|
|||||||
return term();
|
return term();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOST_STATIC_STRING_NORETURN
|
||||||
basic_static_string&
|
basic_static_string&
|
||||||
assign_char(value_type, std::false_type)
|
assign_char(value_type, std::false_type)
|
||||||
{
|
{
|
||||||
BOOST_STATIC_STRING_THROW(
|
BOOST_STATIC_STRING_THROW(
|
||||||
std::length_error{"max_size() == 0"});
|
std::length_error{"max_size() == 0"});
|
||||||
|
// This eliminates any potential warnings
|
||||||
|
#ifdef BOOST_STATIC_STRING_NO_NORETURN
|
||||||
return *this;
|
return *this;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns the size of data read from input iterator. Read data begins at data() + size() + 1.
|
// Returns the size of data read from input iterator. Read data begins at data() + size() + 1.
|
||||||
|
Reference in New Issue
Block a user