Fix compilation error on Android NDK level < 21

This commit is contained in:
badaix 2018-03-13 07:47:40 +01:00
parent 8ce34f818a
commit e9d8f08561
2 changed files with 15 additions and 2 deletions

View file

@ -1948,7 +1948,7 @@ class lexer
/// return the locale-dependent decimal point
static char get_decimal_point() noexcept
{
const auto loc = localeconv();
const auto loc = cpt::localeconv();
assert(loc != nullptr);
return (loc->decimal_point == nullptr) ? '.' : *(loc->decimal_point);
}
@ -8247,7 +8247,7 @@ class serializer
@param[in] ichar indentation character to use
*/
serializer(output_adapter_t<char> s, const char ichar)
: o(std::move(s)), loc(std::localeconv()),
: o(std::move(s)), loc(cpt::localeconv()),
thousands_sep(loc->thousands_sep == nullptr ? '\0' : * (loc->thousands_sep)),
decimal_point(loc->decimal_point == nullptr ? '\0' : * (loc->decimal_point)),
indent_char(ichar), indent_string(512, indent_char)

View file

@ -3,6 +3,7 @@
#include <string>
#include <clocale>
#ifdef NO_CPP11_STRING
#include <sstream>
@ -16,6 +17,18 @@
namespace cpt
{
static struct lconv* localeconv()
{
#ifdef NO_CPP11_STRING
static struct lconv result;
result.decimal_point = nullptr;
result.thousands_sep = nullptr;
return &result;
#else
return std::localeconv();
#endif
}
template<typename T>
static std::string to_string(const T& t)
{