1
0
mirror of https://github.com/nlohmann/json.git synced 2025-07-09 11:01:47 +03:00
This commit is contained in:
Niels
2015-05-06 19:52:12 +02:00
parent 1580eee4ed
commit 17609f244d
4 changed files with 55 additions and 5 deletions

View File

@ -431,7 +431,14 @@ class basic_json
/// create a floating-point number (explicit)
inline basic_json(const number_float_t& value)
: m_type(value_t::number_float), m_value(value)
{}
{
// replace infinity and NAN by null
if (not std::isfinite(value))
{
m_type = value_t::null;
m_value = json_value();
}
}
/// create a floating-point number (implicit)
template<typename T, typename = typename
@ -441,7 +448,14 @@ class basic_json
>
inline basic_json(const T value) noexcept
: m_type(value_t::number_float), m_value(number_float_t(value))
{}
{
// replace infinity and NAN by null
if (not std::isfinite(value))
{
m_type = value_t::null;
m_value = json_value();
}
}
/// create a container (array or object) from an initializer list
inline basic_json(list_init_t init, bool type_deduction = true,