@ -469,14 +469,6 @@ namespace nlohmann
# endif
# endif
// C++ language standard detection
# if (defined(__cplusplus) && __cplusplus >= 201703L) || (defined(_HAS_CXX17) && _HAS_CXX17 == 1) // fix for issue #464
# define JSON_HAS_CPP_17
# define JSON_HAS_CPP_14
# elif (defined(__cplusplus) && __cplusplus >= 201402L) || (defined(_HAS_CXX14) && _HAS_CXX14 == 1)
# define JSON_HAS_CPP_14
# endif
// disable float-equal warnings on GCC/clang
# if defined(__clang__) || defined(__GNUC__) || defined(__GNUG__)
# pragma GCC diagnostic push
@ -501,11 +493,7 @@ namespace nlohmann
// allow for portable nodiscard warnings
# if defined(__has_cpp_attribute)
# if __has_cpp_attribute(nodiscard)
# if defined(__clang__) && !defined(JSON_HAS_CPP_17) // issue #1535
# define JSON_NODISCARD
# else
# define JSON_NODISCARD [[nodiscard]]
# endif
# elif __has_cpp_attribute(gnu::warn_unused_result)
# define JSON_NODISCARD [[gnu::warn_unused_result]]
# else
@ -558,6 +546,14 @@ namespace nlohmann
# define JSON_UNLIKELY(x) x
# endif
// C++ language standard detection
# if (defined(__cplusplus) && __cplusplus >= 201703L) || (defined(_HAS_CXX17) && _HAS_CXX17 == 1) // fix for issue #464
# define JSON_HAS_CPP_17
# define JSON_HAS_CPP_14
# elif (defined(__cplusplus) && __cplusplus >= 201402L) || (defined(_HAS_CXX14) && _HAS_CXX14 == 1)
# define JSON_HAS_CPP_14
# endif
/*!
@ brief macro to briefly define a mapping between an enum and JSON
@ def NLOHMANN_JSON_SERIALIZE_ENUM
@ -1059,19 +1055,10 @@ namespace nlohmann
using object_t = typename BasicJsonType : : object_t ;
static constexpr bool value =
( std : : is_default_constructible < ConstructibleObjectType > : : value and
( std : : is_move_assignable < ConstructibleObjectType > : : value or
std : : is_copy_assignable < ConstructibleObjectType > : : value ) and
( std : : is_constructible < typename ConstructibleObjectType : : key_type ,
typename object_t : : key_type > : : value and
std : : is_same <
typename object_t : : mapped_type ,
typename ConstructibleObjectType : : mapped_type > : : value ) ) or
( has_from_json < BasicJsonType ,
typename ConstructibleObjectType : : mapped_type > : : value or
has_non_default_from_json <
BasicJsonType ,
typename ConstructibleObjectType : : mapped_type > : : value ) ;
( std : : is_constructible < typename ConstructibleObjectType : : key_type , typename object_t : : key_type > : : value and
std : : is_same < typename object_t : : mapped_type , typename ConstructibleObjectType : : mapped_type > : : value ) or
( has_from_json < BasicJsonType , typename ConstructibleObjectType : : mapped_type > : : value or
has_non_default_from_json < BasicJsonType , typename ConstructibleObjectType : : mapped_type > : : value ) ;
} ;
template < typename BasicJsonType , typename ConstructibleObjectType >
@ -1154,9 +1141,6 @@ namespace nlohmann
BasicJsonType , ConstructibleArrayType ,
enable_if_t < not std : : is_same < ConstructibleArrayType ,
typename BasicJsonType : : value_type > : : value and
std : : is_default_constructible < ConstructibleArrayType > : : value and
( std : : is_move_assignable < ConstructibleArrayType > : : value or
std : : is_copy_assignable < ConstructibleArrayType > : : value ) and
is_detected < value_type_t , ConstructibleArrayType > : : value and
is_detected < iterator_t , ConstructibleArrayType > : : value and
is_complete_type <
@ -1164,14 +1148,13 @@ namespace nlohmann
{
static constexpr bool value =
// This is needed because json_reverse_iterator has a ::iterator type,
// furthermore, std::back_insert_iterator (and other iterators) have a
// base class `iterator`... Therefore it is detected as a
// ConstructibleArrayType. The real fix would be to have an Iterable
// concept.
not is_iterator_traits < iterator_traits < ConstructibleArrayType > > : : value and
( std : : is_same < typename ConstructibleArrayType : : value_type ,
typename BasicJsonType : : array_t : : value_type > : : value or
// furthermore, std::back_insert_iterator (and other iterators) have a base class `iterator`...
// Therefore it is detected as a ConstructibleArrayType.
// The real fix would be to have an Iterable concept.
not is_iterator_traits <
iterator_traits < ConstructibleArrayType > > : : value and
( std : : is_same < typename ConstructibleArrayType : : value_type , typename BasicJsonType : : array_t : : value_type > : : value or
has_from_json < BasicJsonType ,
typename ConstructibleArrayType : : value_type > : : value or
has_non_default_from_json <
@ -1424,7 +1407,6 @@ namespace nlohmann
{
JSON_THROW ( type_error : : create ( 302 , " type must be array, but is " + std : : string ( j . type_name ( ) ) ) ) ;
}
l . clear ( ) ;
std : : transform ( j . rbegin ( ) , j . rend ( ) ,
std : : front_inserter ( l ) , [ ] ( const BasicJsonType & i )
{
@ -1445,16 +1427,6 @@ namespace nlohmann
std : : copy ( j . m_value . array - > begin ( ) , j . m_value . array - > end ( ) , std : : begin ( l ) ) ;
}
template < typename BasicJsonType , typename T , std : : size_t N >
auto from_json ( const BasicJsonType & j , T ( & arr ) [ N ] )
- > decltype ( j . template get < T > ( ) , void ( ) )
{
for ( std : : size_t i = 0 ; i < N ; + + i )
{
arr [ i ] = j . at ( i ) . template get < T > ( ) ;
}
}
template < typename BasicJsonType >
void from_json_array_impl ( const BasicJsonType & j , typename BasicJsonType : : array_t & arr , priority_tag < 3 > /*unused*/ )
{
@ -1481,16 +1453,14 @@ namespace nlohmann
{
using std : : end ;
ConstructibleArrayType ret ;
ret . reserve ( j . size ( ) ) ;
arr . reserve ( j . size ( ) ) ;
std : : transform ( j . begin ( ) , j . end ( ) ,
std : : inserter ( ret, end ( ret ) ) , [ ] ( const BasicJsonType & i )
std : : inserter ( arr, end ( arr ) ) , [ ] ( const BasicJsonType & i )
{
// get<BasicJsonType>() returns *this, this won't call a from_json
// method when value_type is BasicJsonType
return i . template get < typename ConstructibleArrayType : : value_type > ( ) ;
} ) ;
arr = std : : move ( ret ) ;
}
template < typename BasicJsonType , typename ConstructibleArrayType >
@ -1499,16 +1469,14 @@ namespace nlohmann
{
using std : : end ;
ConstructibleArrayType ret ;
std : : transform (
j . begin ( ) , j . end ( ) , std : : inserter ( ret, end ( ret ) ) ,
j . begin ( ) , j . end ( ) , std : : inserter ( arr, end ( arr ) ) ,
[ ] ( const BasicJsonType & i )
{
// get<BasicJsonType>() returns *this, this won't call a from_json
// method when value_type is BasicJsonType
return i . template get < typename ConstructibleArrayType : : value_type > ( ) ;
} ) ;
arr = std : : move ( ret ) ;
}
template < typename BasicJsonType , typename ConstructibleArrayType ,
@ -1542,17 +1510,15 @@ namespace nlohmann
JSON_THROW ( type_error : : create ( 302 , " type must be object, but is " + std : : string ( j . type_name ( ) ) ) ) ;
}
ConstructibleObjectType ret ;
auto inner_object = j . template get_ptr < const typename BasicJsonType : : object_t * > ( ) ;
using value_type = typename ConstructibleObjectType : : value_type ;
std : : transform (
inner_object - > begin ( ) , inner_object - > end ( ) ,
std : : inserter ( ret, ret . begin ( ) ) ,
std : : inserter ( obj, obj . begin ( ) ) ,
[ ] ( typename BasicJsonType : : object_t : : value_type const & p )
{
return value_type ( p . first , p . second . template get < typename ConstructibleObjectType : : mapped_type > ( ) ) ;
} ) ;
obj = std : : move ( ret ) ;
}
// overload for arithmetic types, not chosen for basic_json template arguments
@ -1624,7 +1590,6 @@ namespace nlohmann
{
JSON_THROW ( type_error : : create ( 302 , " type must be array, but is " + std : : string ( j . type_name ( ) ) ) ) ;
}
m . clear ( ) ;
for ( const auto & p : j )
{
if ( JSON_UNLIKELY ( not p . is_array ( ) ) )
@ -1644,7 +1609,6 @@ namespace nlohmann
{
JSON_THROW ( type_error : : create ( 302 , " type must be array, but is " + std : : string ( j . type_name ( ) ) ) ) ;
}
m . clear ( ) ;
for ( const auto & p : j )
{
if ( JSON_UNLIKELY ( not p . is_array ( ) ) )
@ -5368,7 +5332,8 @@ namespace nlohmann
do
{
get ( ) ;
} while ( current = = ' N ' ) ;
}
while ( current = = ' N ' ) ;
return current ;
}
@ -6948,7 +6913,8 @@ namespace nlohmann
do
{
get ( ) ;
} while ( current = = ' ' or current = = ' \t ' or current = = ' \n ' or current = = ' \r ' ) ;
}
while ( current = = ' ' or current = = ' \t ' or current = = ' \n ' or current = = ' \r ' ) ;
switch ( current )
{
@ -7819,16 +7785,6 @@ namespace nlohmann
to iterator is not defined .
*/
/*!
@ brief const copy constructor
@ param [ in ] other const iterator to copy from
@ note This copy constuctor had to be defined explicitely to circumvent a bug
occuring on msvc v19 .0 compiler ( VS 2015 ) debug build . For more
information refer to : https : //github.com/nlohmann/json/issues/1608
*/
iter_impl ( const iter_impl < const BasicJsonType > & other ) noexcept
: m_object ( other . m_object ) , m_it ( other . m_it ) { }
/*!
@ brief converting constructor
@ param [ in ] other non - const iterator to copy from
@ -9238,8 +9194,7 @@ namespace nlohmann
pos ! = std : : string : : npos ; // make sure f was found
s . replace ( pos , f . size ( ) , t ) , // replace with t, and
pos = s . find ( f , pos + t . size ( ) ) ) // find next occurrence of f
{
}
{ }
}
/// escape "~" to "~0" and "/" to "~1"
@ -15494,19 +15449,6 @@ namespace nlohmann
return v ;
}
template <
typename T , std : : size_t N ,
typename Array = T ( & ) [ N ] ,
detail : : enable_if_t <
detail : : has_from_json < basic_json_t , Array > : : value , int > = 0 >
Array get_to ( T ( & v ) [ N ] ) const
noexcept ( noexcept ( JSONSerializer < Array > : : from_json (
std : : declval < const basic_json_t & > ( ) , v ) ) )
{
JSONSerializer < Array > : : from_json ( * this , v ) ;
return v ;
}
/*!
@ brief get a pointer value ( implicit )
@ -16198,8 +16140,6 @@ namespace nlohmann
@ return copy of the element at key @ a key or @ a default_value if @ a key
is not found
@ throw type_error .302 if @ a default_value does not match the type of the
value at @ a key
@ throw type_error .306 if the JSON value is not an object ; in that case ,
using ` value ( ) ` with a key makes no sense .
@ -16273,8 +16213,6 @@ namespace nlohmann
@ return copy of the element at key @ a key or @ a default_value if @ a key
is not found
@ throw type_error .302 if @ a default_value does not match the type of the
value at @ a ptr
@ throw type_error .306 if the JSON value is not an object ; in that case ,
using ` value ( ) ` with a key makes no sense .
@ -20779,21 +20717,6 @@ namespace nlohmann
/// @}
} ;
/*!
@ brief user - defined to_string function for JSON values
This function implements a user - defined to_string for JSON objects .
@ param [ in ] j a JSON object
@ return a std : : string object
*/
NLOHMANN_BASIC_JSON_TPL_DECLARATION
std : : string to_string ( const NLOHMANN_BASIC_JSON_TPL & j )
{
return j . dump ( ) ;
}
} // namespace nlohmann
///////////////////////