Fast Methods for Cosmological Simulations
FastSim serves as a tool for quick N-body simulations in modified gravity.
nlohmann::detail Namespace Reference

detail namespace with internal helper functions More...

Namespaces

 dtoa_impl
 implements the Grisu2 algorithm for binary to decimal floating-point conversion.
 

Classes

class  binary_reader
 deserialization of CBOR, MessagePack, and UBJSON values More...
 
class  binary_writer
 serialization to CBOR and MessagePack values More...
 
struct  detector
 
struct  detector< Default, void_t< Op< Args... > >, Op, Args... >
 
class  exception
 general exception of the basic_json class More...
 
struct  external_constructor
 
struct  external_constructor< value_t::array >
 
struct  external_constructor< value_t::boolean >
 
struct  external_constructor< value_t::number_float >
 
struct  external_constructor< value_t::number_integer >
 
struct  external_constructor< value_t::number_unsigned >
 
struct  external_constructor< value_t::object >
 
struct  external_constructor< value_t::string >
 
struct  from_json_fn
 
struct  has_from_json
 
struct  has_from_json< BasicJsonType, T, enable_if_t< not is_basic_json< T >::value > >
 
struct  has_non_default_from_json
 
struct  has_non_default_from_json< BasicJsonType, T, enable_if_t< not is_basic_json< T >::value > >
 
struct  has_to_json
 
struct  has_to_json< BasicJsonType, T, enable_if_t< not is_basic_json< T >::value > >
 
struct  index_sequence
 
class  input_adapter
 
struct  input_adapter_protocol
 abstract input adapter interface More...
 
class  input_buffer_adapter
 input adapter for buffer input More...
 
class  input_stream_adapter
 
struct  internal_iterator
 an iterator value More...
 
class  invalid_iterator
 exception indicating errors with iterators More...
 
struct  is_basic_json
 
struct  is_basic_json< basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer > >
 
struct  is_compatible_array_type
 
struct  is_compatible_array_type_impl
 
struct  is_compatible_array_type_impl< BasicJsonType, CompatibleArrayType, enable_if_t< is_detected< value_type_t, CompatibleArrayType >::value andis_detected< iterator_t, CompatibleArrayType >::value andnot is_iterator_traits< std::iterator_traits< CompatibleArrayType > >::value > >
 
struct  is_compatible_integer_type
 
struct  is_compatible_integer_type_impl
 
struct  is_compatible_integer_type_impl< RealIntegerType, CompatibleNumberIntegerType, enable_if_t< std::is_integral< RealIntegerType >::value andstd::is_integral< CompatibleNumberIntegerType >::value andnot std::is_same< bool, CompatibleNumberIntegerType >::value > >
 
struct  is_compatible_object_type
 
struct  is_compatible_object_type_impl
 
struct  is_compatible_object_type_impl< BasicJsonType, CompatibleObjectType, enable_if_t< is_detected< mapped_type_t, CompatibleObjectType >::value andis_detected< key_type_t, CompatibleObjectType >::value > >
 
struct  is_compatible_string_type
 
struct  is_compatible_string_type_impl
 
struct  is_compatible_string_type_impl< BasicJsonType, CompatibleStringType, enable_if_t< is_detected_exact< typename BasicJsonType::string_t::value_type, value_type_t, CompatibleStringType >::value > >
 
struct  is_compatible_type
 
struct  is_compatible_type_impl
 
struct  is_compatible_type_impl< BasicJsonType, CompatibleType, enable_if_t< is_complete_type< CompatibleType >::value > >
 
struct  is_complete_type
 
struct  is_complete_type< T, decltype(void(sizeof(T)))>
 
struct  is_constructible_array_type
 
struct  is_constructible_array_type_impl
 
struct  is_constructible_array_type_impl< BasicJsonType, ConstructibleArrayType, enable_if_t< not std::is_same< ConstructibleArrayType, typename BasicJsonType::value_type >::value andis_detected< value_type_t, ConstructibleArrayType >::value andis_detected< iterator_t, ConstructibleArrayType >::value andis_complete_type< detected_t< value_type_t, ConstructibleArrayType > >::value > >
 
struct  is_constructible_array_type_impl< BasicJsonType, ConstructibleArrayType, enable_if_t< std::is_same< ConstructibleArrayType, typename BasicJsonType::value_type >::value > >
 
struct  is_constructible_object_type
 
struct  is_constructible_object_type_impl
 
struct  is_constructible_object_type_impl< BasicJsonType, ConstructibleObjectType, enable_if_t< is_detected< mapped_type_t, ConstructibleObjectType >::value andis_detected< key_type_t, ConstructibleObjectType >::value > >
 
struct  is_constructible_string_type
 
struct  is_constructible_string_type_impl
 
struct  is_constructible_string_type_impl< BasicJsonType, ConstructibleStringType, enable_if_t< is_detected_exact< typename BasicJsonType::string_t::value_type, value_type_t, ConstructibleStringType >::value > >
 
struct  is_iterator_traits
 
struct  is_iterator_traits< std::iterator_traits< T > >
 
struct  is_sax
 
struct  is_sax_static_asserts
 
class  iter_impl
 a template for a bidirectional iterator for the basic_json class More...
 
class  iteration_proxy
 proxy class for the items() function More...
 
class  json_ref
 
class  json_reverse_iterator
 a template for a reverse iterator class More...
 
class  json_sax_acceptor
 
class  json_sax_dom_callback_parser
 
class  json_sax_dom_parser
 SAX implementation to create a JSON value from SAX events. More...
 
class  lexer
 lexical analysis More...
 
struct  make_index_sequence
 
struct  make_index_sequence< 0 >
 
struct  make_index_sequence< 1 >
 
struct  make_void
 
struct  merge_and_renumber
 
struct  merge_and_renumber< index_sequence< I1... >, index_sequence< I2... > >
 
struct  nonesuch
 
class  other_error
 exception indicating other library errors More...
 
class  out_of_range
 exception indicating access out of the defined range More...
 
class  output_adapter
 
struct  output_adapter_protocol
 abstract output adapter interface More...
 
class  output_stream_adapter
 output adapter for output streams More...
 
class  output_string_adapter
 output adapter for basic_string More...
 
class  output_vector_adapter
 output adapter for byte vectors More...
 
class  parse_error
 exception indicating a parse error More...
 
class  parser
 syntax analysis More...
 
struct  position_t
 struct to capture the start position of the current token More...
 
class  primitive_iterator_t
 
struct  priority_tag
 
struct  priority_tag< 0 >
 
class  serializer
 
struct  static_const
 
struct  to_json_fn
 
class  type_error
 exception indicating executing a member function with a wrong type More...
 
class  wide_string_input_adapter
 
struct  wide_string_input_helper
 
struct  wide_string_input_helper< WideStringType, 2 >
 

Typedefs

template<bool B, typename T = void>
using enable_if_t = typename std::enable_if< B, T >::type
 
template<typename T >
using uncvref_t = typename std::remove_cv< typename std::remove_reference< T >::type >::type
 
template<typename... Ts>
using index_sequence_for = make_index_sequence< sizeof...(Ts)>
 
template<typename... Ts>
using void_t = typename make_void< Ts... >::type
 
template<template< class... > class Op, class... Args>
using is_detected = typename detector< nonesuch, void, Op, Args... >::value_t
 
template<template< class... > class Op, class... Args>
using detected_t = typename detector< nonesuch, void, Op, Args... >::type
 
template<class Default , template< class... > class Op, class... Args>
using detected_or = detector< Default, void, Op, Args... >
 
template<class Default , template< class... > class Op, class... Args>
using detected_or_t = typename detected_or< Default, Op, Args... >::type
 
template<class Expected , template< class... > class Op, class... Args>
using is_detected_exact = std::is_same< Expected, detected_t< Op, Args... >>
 
template<class To , template< class... > class Op, class... Args>
using is_detected_convertible = std::is_convertible< detected_t< Op, Args... >, To >
 
template<typename T >
using mapped_type_t = typename T::mapped_type
 
template<typename T >
using key_type_t = typename T::key_type
 
template<typename T >
using value_type_t = typename T::value_type
 
template<typename T >
using difference_type_t = typename T::difference_type
 
template<typename T >
using pointer_t = typename T::pointer
 
template<typename T >
using reference_t = typename T::reference
 
template<typename T >
using iterator_category_t = typename T::iterator_category
 
template<typename T >
using iterator_t = typename T::iterator
 
template<typename T , typename... Args>
using to_json_function = decltype(T::to_json(std::declval< Args >()...))
 
template<typename T , typename... Args>
using from_json_function = decltype(T::from_json(std::declval< Args >()...))
 
template<typename T , typename U >
using get_template_function = decltype(std::declval< T >().template get< U >())
 
using input_adapter_t = std::shared_ptr< input_adapter_protocol >
 a type to simplify interfaces More...
 
template<typename T >
using null_function_t = decltype(std::declval< T & >().null())
 
template<typename T >
using boolean_function_t = decltype(std::declval< T & >().boolean(std::declval< bool >()))
 
template<typename T , typename Integer >
using number_integer_function_t = decltype(std::declval< T & >().number_integer(std::declval< Integer >()))
 
template<typename T , typename Unsigned >
using number_unsigned_function_t = decltype(std::declval< T & >().number_unsigned(std::declval< Unsigned >()))
 
template<typename T , typename Float , typename String >
using number_float_function_t = decltype(std::declval< T & >().number_float(std::declval< Float >(), std::declval< const String & >()))
 
template<typename T , typename String >
using string_function_t = decltype(std::declval< T & >().string(std::declval< String & >()))
 
template<typename T >
using start_object_function_t = decltype(std::declval< T & >().start_object(std::declval< std::size_t >()))
 
template<typename T , typename String >
using key_function_t = decltype(std::declval< T & >().key(std::declval< String & >()))
 
template<typename T >
using end_object_function_t = decltype(std::declval< T & >().end_object())
 
template<typename T >
using start_array_function_t = decltype(std::declval< T & >().start_array(std::declval< std::size_t >()))
 
template<typename T >
using end_array_function_t = decltype(std::declval< T & >().end_array())
 
template<typename T , typename Exception >
using parse_error_function_t = decltype(std::declval< T & >().parse_error(std::declval< std::size_t >(), std::declval< const std::string & >(), std::declval< const Exception & >()))
 
template<typename CharType >
using output_adapter_t = std::shared_ptr< output_adapter_protocol< CharType >>
 a type to simplify interfaces More...
 

Enumerations

enum  value_t : std::uint8_t {
  value_t::null, value_t::object, value_t::array, value_t::string,
  value_t::boolean, value_t::number_integer, value_t::number_unsigned, value_t::number_float,
  value_t::discarded
}
 the JSON type enumeration More...
 
enum  input_format_t {
  input_format_t::json, input_format_t::cbor, input_format_t::msgpack, input_format_t::ubjson,
  input_format_t::bson
}
 the supported input formats More...
 
enum  error_handler_t { error_handler_t::strict, error_handler_t::replace, error_handler_t::ignore }
 how to treat decoding errors More...
 

Functions

bool operator< (const value_t lhs, const value_t rhs) noexcept
 comparison operator for JSON types More...
 
template<typename BasicJsonType >
void from_json (const BasicJsonType &j, typename std::nullptr_t &n)
 
template<typename BasicJsonType , typename ArithmeticType , enable_if_t< std::is_arithmetic< ArithmeticType >::value andnot std::is_same< ArithmeticType, typename BasicJsonType::boolean_t >::value, int > = 0>
void get_arithmetic_value (const BasicJsonType &j, ArithmeticType &val)
 
template<typename BasicJsonType >
void from_json (const BasicJsonType &j, typename BasicJsonType::boolean_t &b)
 
template<typename BasicJsonType >
void from_json (const BasicJsonType &j, typename BasicJsonType::string_t &s)
 
template<typename BasicJsonType , typename ConstructibleStringType , enable_if_t< is_constructible_string_type< BasicJsonType, ConstructibleStringType >::value andnot std::is_same< typename BasicJsonType::string_t, ConstructibleStringType >::value, int > = 0>
void from_json (const BasicJsonType &j, ConstructibleStringType &s)
 
template<typename BasicJsonType >
void from_json (const BasicJsonType &j, typename BasicJsonType::number_float_t &val)
 
template<typename BasicJsonType >
void from_json (const BasicJsonType &j, typename BasicJsonType::number_unsigned_t &val)
 
template<typename BasicJsonType >
void from_json (const BasicJsonType &j, typename BasicJsonType::number_integer_t &val)
 
template<typename BasicJsonType , typename EnumType , enable_if_t< std::is_enum< EnumType >::value, int > = 0>
void from_json (const BasicJsonType &j, EnumType &e)
 
template<typename BasicJsonType , typename T , typename Allocator , enable_if_t< std::is_convertible< BasicJsonType, T >::value, int > = 0>
void from_json (const BasicJsonType &j, std::forward_list< T, Allocator > &l)
 
template<typename BasicJsonType , typename T , enable_if_t< std::is_convertible< BasicJsonType, T >::value, int > = 0>
void from_json (const BasicJsonType &j, std::valarray< T > &l)
 
template<typename BasicJsonType >
void from_json_array_impl (const BasicJsonType &j, typename BasicJsonType::array_t &arr, priority_tag< 3 >)
 
template<typename BasicJsonType , typename T , std::size_t N>
auto from_json_array_impl (const BasicJsonType &j, std::array< T, N > &arr, priority_tag< 2 >) -> decltype(j.template get< T >(), void())
 
template<typename BasicJsonType , typename ConstructibleArrayType >
auto from_json_array_impl (const BasicJsonType &j, ConstructibleArrayType &arr, priority_tag< 1 >) -> decltype(arr.reserve(std::declval< typename ConstructibleArrayType::size_type >()), j.template get< typename ConstructibleArrayType::value_type >(), void())
 
template<typename BasicJsonType , typename ConstructibleArrayType >
void from_json_array_impl (const BasicJsonType &j, ConstructibleArrayType &arr, priority_tag< 0 >)
 
template<typename BasicJsonType , typename ConstructibleArrayType , enable_if_t< is_constructible_array_type< BasicJsonType, ConstructibleArrayType >::value andnot is_constructible_object_type< BasicJsonType, ConstructibleArrayType >::value andnot is_constructible_string_type< BasicJsonType, ConstructibleArrayType >::value andnot is_basic_json< ConstructibleArrayType >::value, int > = 0>
auto from_json (const BasicJsonType &j, ConstructibleArrayType &arr) -> decltype(from_json_array_impl(j, arr, priority_tag< 3 >
 
j template get< typename ConstructibleArrayType::value_type > ()
 
j template void ())
 
template<typename BasicJsonType , typename ConstructibleObjectType , enable_if_t< is_constructible_object_type< BasicJsonType, ConstructibleObjectType >::value, int > = 0>
void from_json (const BasicJsonType &j, ConstructibleObjectType &obj)
 
template<typename BasicJsonType , typename ArithmeticType , enable_if_t< std::is_arithmetic< ArithmeticType >::value andnot std::is_same< ArithmeticType, typename BasicJsonType::number_unsigned_t >::value andnot std::is_same< ArithmeticType, typename BasicJsonType::number_integer_t >::value andnot std::is_same< ArithmeticType, typename BasicJsonType::number_float_t >::value andnot std::is_same< ArithmeticType, typename BasicJsonType::boolean_t >::value, int > = 0>
void from_json (const BasicJsonType &j, ArithmeticType &val)
 
template<typename BasicJsonType , typename A1 , typename A2 >
void from_json (const BasicJsonType &j, std::pair< A1, A2 > &p)
 
template<typename BasicJsonType , typename Tuple , std::size_t... Idx>
void from_json_tuple_impl (const BasicJsonType &j, Tuple &t, index_sequence< Idx... >)
 
template<typename BasicJsonType , typename... Args>
void from_json (const BasicJsonType &j, std::tuple< Args... > &t)
 
template<typename BasicJsonType , typename Key , typename Value , typename Compare , typename Allocator , typename = enable_if_t<not std::is_constructible< typename BasicJsonType::string_t, Key>::value>>
void from_json (const BasicJsonType &j, std::map< Key, Value, Compare, Allocator > &m)
 
template<typename BasicJsonType , typename Key , typename Value , typename Hash , typename KeyEqual , typename Allocator , typename = enable_if_t<not std::is_constructible< typename BasicJsonType::string_t, Key>::value>>
void from_json (const BasicJsonType &j, std::unordered_map< Key, Value, Hash, KeyEqual, Allocator > &m)
 
template<typename BasicJsonType , typename T , enable_if_t< std::is_same< T, typename BasicJsonType::boolean_t >::value, int > = 0>
void to_json (BasicJsonType &j, T b) noexcept
 
template<typename BasicJsonType , typename CompatibleString , enable_if_t< std::is_constructible< typename BasicJsonType::string_t, CompatibleString >::value, int > = 0>
void to_json (BasicJsonType &j, const CompatibleString &s)
 
template<typename BasicJsonType >
void to_json (BasicJsonType &j, typename BasicJsonType::string_t &&s)
 
template<typename BasicJsonType , typename FloatType , enable_if_t< std::is_floating_point< FloatType >::value, int > = 0>
void to_json (BasicJsonType &j, FloatType val) noexcept
 
template<typename BasicJsonType , typename CompatibleNumberUnsignedType , enable_if_t< is_compatible_integer_type< typename BasicJsonType::number_unsigned_t, CompatibleNumberUnsignedType >::value, int > = 0>
void to_json (BasicJsonType &j, CompatibleNumberUnsignedType val) noexcept
 
template<typename BasicJsonType , typename CompatibleNumberIntegerType , enable_if_t< is_compatible_integer_type< typename BasicJsonType::number_integer_t, CompatibleNumberIntegerType >::value, int > = 0>
void to_json (BasicJsonType &j, CompatibleNumberIntegerType val) noexcept
 
template<typename BasicJsonType , typename EnumType , enable_if_t< std::is_enum< EnumType >::value, int > = 0>
void to_json (BasicJsonType &j, EnumType e) noexcept
 
template<typename BasicJsonType >
void to_json (BasicJsonType &j, const std::vector< bool > &e)
 
template<typename BasicJsonType , typename CompatibleArrayType , enable_if_t< is_compatible_array_type< BasicJsonType, CompatibleArrayType >::value andnot is_compatible_object_type< BasicJsonType, CompatibleArrayType >::value andnot is_compatible_string_type< BasicJsonType, CompatibleArrayType >::value andnot is_basic_json< CompatibleArrayType >::value, int > = 0>
void to_json (BasicJsonType &j, const CompatibleArrayType &arr)
 
template<typename BasicJsonType , typename T , enable_if_t< std::is_convertible< T, BasicJsonType >::value, int > = 0>
void to_json (BasicJsonType &j, const std::valarray< T > &arr)
 
template<typename BasicJsonType >
void to_json (BasicJsonType &j, typename BasicJsonType::array_t &&arr)
 
template<typename BasicJsonType , typename CompatibleObjectType , enable_if_t< is_compatible_object_type< BasicJsonType, CompatibleObjectType >::value and not is_basic_json< CompatibleObjectType >::value, int > = 0>
void to_json (BasicJsonType &j, const CompatibleObjectType &obj)
 
template<typename BasicJsonType >
void to_json (BasicJsonType &j, typename BasicJsonType::object_t &&obj)
 
template<typename BasicJsonType , typename T , std::size_t N, enable_if_t< not std::is_constructible< typename BasicJsonType::string_t, const T(&)[N]>::value, int > = 0>
void to_json (BasicJsonType &j, const T(&arr)[N])
 
template<typename BasicJsonType , typename... Args>
void to_json (BasicJsonType &j, const std::pair< Args... > &p)
 
template<typename BasicJsonType , typename T , enable_if_t< std::is_same< T, typename iteration_proxy< typename BasicJsonType::iterator >::iteration_proxy_internal >::value, int > = 0>
void to_json (BasicJsonType &j, const T &b)
 
template<typename BasicJsonType , typename Tuple , std::size_t... Idx>
void to_json_tuple_impl (BasicJsonType &j, const Tuple &t, index_sequence< Idx... >)
 
template<typename BasicJsonType , typename... Args>
void to_json (BasicJsonType &j, const std::tuple< Args... > &t)
 
template<typename FloatType >
char * to_chars (char *first, const char *last, FloatType value)
 generates a decimal representation of the floating-point number value in [first, last). More...
 

Detailed Description

detail namespace with internal helper functions

This namespace collects functions that should not be exposed, implementations of some basic_json methods, and meta-programming helpers.

Since
version 2.1.0

Typedef Documentation

template<typename T >
using nlohmann::detail::boolean_function_t = typedef decltype(std::declval<T&>().boolean(std::declval<bool>()))

Definition at line 3988 of file json.hpp.

template<class Default , template< class... > class Op, class... Args>
using nlohmann::detail::detected_or = typedef detector<Default, void, Op, Args...>

Definition at line 387 of file json.hpp.

template<class Default , template< class... > class Op, class... Args>
using nlohmann::detail::detected_or_t = typedef typename detected_or<Default, Op, Args...>::type

Definition at line 390 of file json.hpp.

template<template< class... > class Op, class... Args>
using nlohmann::detail::detected_t = typedef typename detector<nonesuch, void, Op, Args...>::type

Definition at line 384 of file json.hpp.

template<typename T >
using nlohmann::detail::difference_type_t = typedef typename T::difference_type

Definition at line 448 of file json.hpp.

template<bool B, typename T = void>
using nlohmann::detail::enable_if_t = typedef typename std::enable_if<B, T>::type

Definition at line 265 of file json.hpp.

template<typename T >
using nlohmann::detail::end_array_function_t = typedef decltype(std::declval<T&>().end_array())

Definition at line 4022 of file json.hpp.

template<typename T >
using nlohmann::detail::end_object_function_t = typedef decltype(std::declval<T&>().end_object())

Definition at line 4015 of file json.hpp.

template<typename T , typename... Args>
using nlohmann::detail::from_json_function = typedef decltype(T::from_json(std::declval<Args>()...))

Definition at line 466 of file json.hpp.

template<typename T , typename U >
using nlohmann::detail::get_template_function = typedef decltype(std::declval<T>().template get<U>())

Definition at line 469 of file json.hpp.

template<typename... Ts>
using nlohmann::detail::index_sequence_for = typedef make_index_sequence<sizeof...(Ts)>

Definition at line 299 of file json.hpp.

a type to simplify interfaces

Definition at line 2095 of file json.hpp.

template<template< class... > class Op, class... Args>
using nlohmann::detail::is_detected = typedef typename detector<nonesuch, void, Op, Args...>::value_t

Definition at line 381 of file json.hpp.

template<class To , template< class... > class Op, class... Args>
using nlohmann::detail::is_detected_convertible = typedef std::is_convertible<detected_t<Op, Args...>, To>

Definition at line 397 of file json.hpp.

template<class Expected , template< class... > class Op, class... Args>
using nlohmann::detail::is_detected_exact = typedef std::is_same<Expected, detected_t<Op, Args...>>

Definition at line 393 of file json.hpp.

template<typename T >
using nlohmann::detail::iterator_category_t = typedef typename T::iterator_category

Definition at line 457 of file json.hpp.

template<typename T >
using nlohmann::detail::iterator_t = typedef typename T::iterator

Definition at line 460 of file json.hpp.

template<typename T , typename String >
using nlohmann::detail::key_function_t = typedef decltype(std::declval<T&>().key(std::declval<String&>()))

Definition at line 4012 of file json.hpp.

template<typename T >
using nlohmann::detail::key_type_t = typedef typename T::key_type

Definition at line 442 of file json.hpp.

template<typename T >
using nlohmann::detail::mapped_type_t = typedef typename T::mapped_type

Definition at line 439 of file json.hpp.

template<typename T >
using nlohmann::detail::null_function_t = typedef decltype(std::declval<T&>().null())

Definition at line 3984 of file json.hpp.

template<typename T , typename Float , typename String >
using nlohmann::detail::number_float_function_t = typedef decltype(std::declval<T&>().number_float( std::declval<Float>(), std::declval<const String&>()))

Definition at line 4000 of file json.hpp.

template<typename T , typename Integer >
using nlohmann::detail::number_integer_function_t = typedef decltype(std::declval<T&>().number_integer(std::declval<Integer>()))

Definition at line 3992 of file json.hpp.

template<typename T , typename Unsigned >
using nlohmann::detail::number_unsigned_function_t = typedef decltype(std::declval<T&>().number_unsigned(std::declval<Unsigned>()))

Definition at line 3996 of file json.hpp.

template<typename CharType >
using nlohmann::detail::output_adapter_t = typedef std::shared_ptr<output_adapter_protocol<CharType>>

a type to simplify interfaces

Definition at line 6234 of file json.hpp.

template<typename T , typename Exception >
using nlohmann::detail::parse_error_function_t = typedef decltype(std::declval<T&>().parse_error( std::declval<std::size_t>(), std::declval<const std::string&>(), std::declval<const Exception&>()))

Definition at line 4027 of file json.hpp.

template<typename T >
using nlohmann::detail::pointer_t = typedef typename T::pointer

Definition at line 451 of file json.hpp.

template<typename T >
using nlohmann::detail::reference_t = typedef typename T::reference

Definition at line 454 of file json.hpp.

template<typename T >
using nlohmann::detail::start_array_function_t = typedef decltype(std::declval<T&>().start_array(std::declval<std::size_t>()))

Definition at line 4019 of file json.hpp.

template<typename T >
using nlohmann::detail::start_object_function_t = typedef decltype(std::declval<T&>().start_object(std::declval<std::size_t>()))

Definition at line 4008 of file json.hpp.

template<typename T , typename String >
using nlohmann::detail::string_function_t = typedef decltype(std::declval<T&>().string(std::declval<String&>()))

Definition at line 4004 of file json.hpp.

template<typename T , typename... Args>
using nlohmann::detail::to_json_function = typedef decltype(T::to_json(std::declval<Args>()...))

Definition at line 463 of file json.hpp.

template<typename T >
using nlohmann::detail::uncvref_t = typedef typename std::remove_cv<typename std::remove_reference<T>::type>::type

Definition at line 268 of file json.hpp.

template<typename T >
using nlohmann::detail::value_type_t = typedef typename T::value_type

Definition at line 445 of file json.hpp.

template<typename... Ts>
using nlohmann::detail::void_t = typedef typename make_void<Ts...>::type

Definition at line 345 of file json.hpp.

Enumeration Type Documentation

how to treat decoding errors

Enumerator
strict 

throw a type_error exception in case of invalid UTF-8

replace 

replace invalid UTF-8 sequences with U+FFFD

ignore 

ignore invalid UTF-8 sequences

Definition at line 10795 of file json.hpp.

10796 {
10797  strict,
10798  replace,
10799  ignore
10800 };
ignore invalid UTF-8 sequences
throw a type_error exception in case of invalid UTF-8
replace invalid UTF-8 sequences with U+FFFD

the supported input formats

Enumerator
json 
cbor 
msgpack 
ubjson 
bson 

Definition at line 2070 of file json.hpp.

enum nlohmann::detail::value_t : std::uint8_t
strong

the JSON type enumeration

This enumeration collects the different JSON types. It is internally used to distinguish the stored values, and the functions basic_json::is_null(), basic_json::is_object(), basic_json::is_array(), basic_json::is_string(), basic_json::is_boolean(), basic_json::is_number() (with basic_json::is_number_integer(), basic_json::is_number_unsigned(), and basic_json::is_number_float()), basic_json::is_discarded(), basic_json::is_primitive(), and basic_json::is_structured() rely on it.

Note
There are three enumeration entries (number_integer, number_unsigned, and number_float), because the library distinguishes these three types for numbers: basic_json::number_unsigned_t is used for unsigned integers, basic_json::number_integer_t is used for signed integers, and basic_json::number_float_t is used for floating-point numbers or to approximate integers which do not fit in the limits of their respective type.
See also
basic_json::basic_json(const value_t value_type) – create a JSON value with the default value for a given type
Since
version 1.0.0
Enumerator
null 

null value

object 

object (unordered set of name/value pairs)

array 

array (ordered collection of values)

string 

string value

boolean 

boolean value

number_integer 

number value (signed integer)

number_unsigned 

number value (unsigned integer)

number_float 

number value (floating-point)

discarded 

discarded by the the parser callback function

Definition at line 1159 of file json.hpp.

1159  : std::uint8_t
1160 {
1161  null,
1162  object,
1163  array,
1164  string,
1165  boolean,
1166  number_integer,
1167  number_unsigned,
1168  number_float,
1169  discarded
1170 };
array (ordered collection of values)
number value (signed integer)
object (unordered set of name/value pairs)
number value (unsigned integer)
number value (floating-point)
discarded by the the parser callback function

Function Documentation

template<typename BasicJsonType >
void nlohmann::detail::from_json ( const BasicJsonType &  j,
typename std::nullptr_t &  n 
)

Definition at line 1229 of file json.hpp.

References nlohmann::detail::type_error::create(), JSON_THROW, JSON_UNLIKELY, string, and Catch::Generators::value().

Referenced by nlohmann::detail::from_json_fn::operator()().

1230 {
1231  if (JSON_UNLIKELY(not j.is_null()))
1232  {
1233  JSON_THROW(type_error::create(302, "type must be null, but is " + std::string(j.type_name())));
1234  }
1235  n = nullptr;
1236 }
#define JSON_UNLIKELY(x)
Definition: json.hpp:194
#define JSON_THROW(exception)
Definition: json.hpp:162
template<typename BasicJsonType >
void nlohmann::detail::from_json ( const BasicJsonType &  j,
typename BasicJsonType::boolean_t &  b 
)

Definition at line 1269 of file json.hpp.

References nlohmann::detail::type_error::create(), JSON_THROW, JSON_UNLIKELY, and string.

1270 {
1271  if (JSON_UNLIKELY(not j.is_boolean()))
1272  {
1273  JSON_THROW(type_error::create(302, "type must be boolean, but is " + std::string(j.type_name())));
1274  }
1275  b = *j.template get_ptr<const typename BasicJsonType::boolean_t*>();
1276 }
#define JSON_UNLIKELY(x)
Definition: json.hpp:194
#define JSON_THROW(exception)
Definition: json.hpp:162
template<typename BasicJsonType >
void nlohmann::detail::from_json ( const BasicJsonType &  j,
typename BasicJsonType::string_t &  s 
)

Definition at line 1279 of file json.hpp.

References nlohmann::detail::type_error::create(), JSON_THROW, JSON_UNLIKELY, string, and Catch::Generators::value().

1280 {
1281  if (JSON_UNLIKELY(not j.is_string()))
1282  {
1283  JSON_THROW(type_error::create(302, "type must be string, but is " + std::string(j.type_name())));
1284  }
1285  s = *j.template get_ptr<const typename BasicJsonType::string_t*>();
1286 }
#define JSON_UNLIKELY(x)
Definition: json.hpp:194
#define JSON_THROW(exception)
Definition: json.hpp:162
template<typename BasicJsonType , typename ConstructibleStringType , enable_if_t< is_constructible_string_type< BasicJsonType, ConstructibleStringType >::value andnot std::is_same< typename BasicJsonType::string_t, ConstructibleStringType >::value, int > = 0>
void nlohmann::detail::from_json ( const BasicJsonType &  j,
ConstructibleStringType &  s 
)

Definition at line 1295 of file json.hpp.

References nlohmann::detail::type_error::create(), JSON_THROW, JSON_UNLIKELY, and string.

1296 {
1297  if (JSON_UNLIKELY(not j.is_string()))
1298  {
1299  JSON_THROW(type_error::create(302, "type must be string, but is " + std::string(j.type_name())));
1300  }
1301 
1302  s = *j.template get_ptr<const typename BasicJsonType::string_t*>();
1303 }
#define JSON_UNLIKELY(x)
Definition: json.hpp:194
#define JSON_THROW(exception)
Definition: json.hpp:162
template<typename BasicJsonType >
void nlohmann::detail::from_json ( const BasicJsonType &  j,
typename BasicJsonType::number_float_t &  val 
)

Definition at line 1306 of file json.hpp.

References get_arithmetic_value().

1307 {
1308  get_arithmetic_value(j, val);
1309 }
void get_arithmetic_value(const BasicJsonType &j, ArithmeticType &val)
Definition: json.hpp:1243
template<typename BasicJsonType >
void nlohmann::detail::from_json ( const BasicJsonType &  j,
typename BasicJsonType::number_unsigned_t &  val 
)

Definition at line 1312 of file json.hpp.

References get_arithmetic_value().

1313 {
1314  get_arithmetic_value(j, val);
1315 }
void get_arithmetic_value(const BasicJsonType &j, ArithmeticType &val)
Definition: json.hpp:1243
template<typename BasicJsonType >
void nlohmann::detail::from_json ( const BasicJsonType &  j,
typename BasicJsonType::number_integer_t &  val 
)

Definition at line 1318 of file json.hpp.

References get_arithmetic_value().

1319 {
1320  get_arithmetic_value(j, val);
1321 }
void get_arithmetic_value(const BasicJsonType &j, ArithmeticType &val)
Definition: json.hpp:1243
template<typename BasicJsonType , typename EnumType , enable_if_t< std::is_enum< EnumType >::value, int > = 0>
void nlohmann::detail::from_json ( const BasicJsonType &  j,
EnumType &  e 
)

Definition at line 1325 of file json.hpp.

References get_arithmetic_value(), and growth_allz::T.

1326 {
1327  typename std::underlying_type<EnumType>::type val;
1328  get_arithmetic_value(j, val);
1329  e = static_cast<EnumType>(val);
1330 }
void get_arithmetic_value(const BasicJsonType &j, ArithmeticType &val)
Definition: json.hpp:1243
template<typename BasicJsonType , typename T , typename Allocator , enable_if_t< std::is_convertible< BasicJsonType, T >::value, int > = 0>
void nlohmann::detail::from_json ( const BasicJsonType &  j,
std::forward_list< T, Allocator > &  l 
)

Definition at line 1335 of file json.hpp.

References nlohmann::detail::type_error::create(), JSON_THROW, JSON_UNLIKELY, string, and growth_allz::T.

1336 {
1337  if (JSON_UNLIKELY(not j.is_array()))
1338  {
1339  JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(j.type_name())));
1340  }
1341  std::transform(j.rbegin(), j.rend(),
1342  std::front_inserter(l), [](const BasicJsonType & i)
1343  {
1344  return i.template get<T>();
1345  });
1346 }
#define JSON_UNLIKELY(x)
Definition: json.hpp:194
#define JSON_THROW(exception)
Definition: json.hpp:162
template<typename BasicJsonType , typename T , enable_if_t< std::is_convertible< BasicJsonType, T >::value, int > = 0>
void nlohmann::detail::from_json ( const BasicJsonType &  j,
std::valarray< T > &  l 
)

Definition at line 1351 of file json.hpp.

References Catch::begin, nlohmann::detail::type_error::create(), JSON_THROW, JSON_UNLIKELY, and string.

1352 {
1353  if (JSON_UNLIKELY(not j.is_array()))
1354  {
1355  JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(j.type_name())));
1356  }
1357  l.resize(j.size());
1358  std::copy(j.m_value.array->begin(), j.m_value.array->end(), std::begin(l));
1359 }
#define JSON_UNLIKELY(x)
Definition: json.hpp:194
not_this_one begin(...)
#define JSON_THROW(exception)
Definition: json.hpp:162
template<typename BasicJsonType , typename ConstructibleArrayType , enable_if_t< is_constructible_array_type< BasicJsonType, ConstructibleArrayType >::value andnot is_constructible_object_type< BasicJsonType, ConstructibleArrayType >::value andnot is_constructible_string_type< BasicJsonType, ConstructibleArrayType >::value andnot is_basic_json< ConstructibleArrayType >::value, int > = 0>
auto nlohmann::detail::from_json ( const BasicJsonType &  j,
ConstructibleArrayType &  arr 
) -> decltype(from_json_array_impl(j, arr, priority_tag<3>

Definition at line 1421 of file json.hpp.

1422  {}),
template<typename BasicJsonType , typename ConstructibleObjectType , enable_if_t< is_constructible_object_type< BasicJsonType, ConstructibleObjectType >::value, int > = 0>
void nlohmann::detail::from_json ( const BasicJsonType &  j,
ConstructibleObjectType &  obj 
)

Definition at line 1437 of file json.hpp.

References nlohmann::detail::type_error::create(), JSON_THROW, JSON_UNLIKELY, p, string, and Catch::Generators::value().

1438 {
1439  if (JSON_UNLIKELY(not j.is_object()))
1440  {
1441  JSON_THROW(type_error::create(302, "type must be object, but is " + std::string(j.type_name())));
1442  }
1443 
1444  auto inner_object = j.template get_ptr<const typename BasicJsonType::object_t*>();
1445  using value_type = typename ConstructibleObjectType::value_type;
1446  std::transform(
1447  inner_object->begin(), inner_object->end(),
1448  std::inserter(obj, obj.begin()),
1449  [](typename BasicJsonType::object_t::value_type const & p)
1450  {
1451  return value_type(p.first, p.second.template get<typename ConstructibleObjectType::mapped_type>());
1452  });
1453 }
#define JSON_UNLIKELY(x)
Definition: json.hpp:194
#define JSON_THROW(exception)
Definition: json.hpp:162
static int p
Definition: ccl_emu17.c:25
template<typename BasicJsonType , typename ArithmeticType , enable_if_t< std::is_arithmetic< ArithmeticType >::value andnot std::is_same< ArithmeticType, typename BasicJsonType::number_unsigned_t >::value andnot std::is_same< ArithmeticType, typename BasicJsonType::number_integer_t >::value andnot std::is_same< ArithmeticType, typename BasicJsonType::number_float_t >::value andnot std::is_same< ArithmeticType, typename BasicJsonType::boolean_t >::value, int > = 0>
void nlohmann::detail::from_json ( const BasicJsonType &  j,
ArithmeticType &  val 
)

Definition at line 1467 of file json.hpp.

References boolean, nlohmann::detail::type_error::create(), JSON_THROW, number_float, number_integer, number_unsigned, and string.

1468 {
1469  switch (static_cast<value_t>(j))
1470  {
1471  case value_t::number_unsigned:
1472  {
1473  val = static_cast<ArithmeticType>(*j.template get_ptr<const typename BasicJsonType::number_unsigned_t*>());
1474  break;
1475  }
1476  case value_t::number_integer:
1477  {
1478  val = static_cast<ArithmeticType>(*j.template get_ptr<const typename BasicJsonType::number_integer_t*>());
1479  break;
1480  }
1481  case value_t::number_float:
1482  {
1483  val = static_cast<ArithmeticType>(*j.template get_ptr<const typename BasicJsonType::number_float_t*>());
1484  break;
1485  }
1486  case value_t::boolean:
1487  {
1488  val = static_cast<ArithmeticType>(*j.template get_ptr<const typename BasicJsonType::boolean_t*>());
1489  break;
1490  }
1491 
1492  default:
1493  JSON_THROW(type_error::create(302, "type must be number, but is " + std::string(j.type_name())));
1494  }
1495 }
#define JSON_THROW(exception)
Definition: json.hpp:162
template<typename BasicJsonType , typename A1 , typename A2 >
void nlohmann::detail::from_json ( const BasicJsonType &  j,
std::pair< A1, A2 > &  p 
)

Definition at line 1498 of file json.hpp.

1499 {
1500  p = {j.at(0).template get<A1>(), j.at(1).template get<A2>()};
1501 }
static int p
Definition: ccl_emu17.c:25
template<typename BasicJsonType , typename... Args>
void nlohmann::detail::from_json ( const BasicJsonType &  j,
std::tuple< Args... > &  t 
)

Definition at line 1510 of file json.hpp.

References from_json_tuple_impl().

1511 {
1512  from_json_tuple_impl(j, t, index_sequence_for<Args...> {});
1513 }
void from_json_tuple_impl(const BasicJsonType &j, Tuple &t, index_sequence< Idx... >)
Definition: json.hpp:1504
template<typename BasicJsonType , typename Key , typename Value , typename Compare , typename Allocator , typename = enable_if_t<not std::is_constructible< typename BasicJsonType::string_t, Key>::value>>
void nlohmann::detail::from_json ( const BasicJsonType &  j,
std::map< Key, Value, Compare, Allocator > &  m 
)

Definition at line 1518 of file json.hpp.

References nlohmann::detail::type_error::create(), JSON_THROW, JSON_UNLIKELY, p, and string.

1519 {
1520  if (JSON_UNLIKELY(not j.is_array()))
1521  {
1522  JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(j.type_name())));
1523  }
1524  for (const auto& p : j)
1525  {
1526  if (JSON_UNLIKELY(not p.is_array()))
1527  {
1528  JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(p.type_name())));
1529  }
1530  m.emplace(p.at(0).template get<Key>(), p.at(1).template get<Value>());
1531  }
1532 }
#define JSON_UNLIKELY(x)
Definition: json.hpp:194
#define JSON_THROW(exception)
Definition: json.hpp:162
static int p
Definition: ccl_emu17.c:25
static int m[2]
Definition: ccl_emu17.c:25
template<typename BasicJsonType , typename Key , typename Value , typename Hash , typename KeyEqual , typename Allocator , typename = enable_if_t<not std::is_constructible< typename BasicJsonType::string_t, Key>::value>>
void nlohmann::detail::from_json ( const BasicJsonType &  j,
std::unordered_map< Key, Value, Hash, KeyEqual, Allocator > &  m 
)

Definition at line 1537 of file json.hpp.

References nlohmann::detail::type_error::create(), JSON_THROW, JSON_UNLIKELY, p, and string.

Referenced by nlohmann::adl_serializer< typename, typename >::from_json(), nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer >::get(), and nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer >::get_to().

1538 {
1539  if (JSON_UNLIKELY(not j.is_array()))
1540  {
1541  JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(j.type_name())));
1542  }
1543  for (const auto& p : j)
1544  {
1545  if (JSON_UNLIKELY(not p.is_array()))
1546  {
1547  JSON_THROW(type_error::create(302, "type must be array, but is " + std::string(p.type_name())));
1548  }
1549  m.emplace(p.at(0).template get<Key>(), p.at(1).template get<Value>());
1550  }
1551 }
#define JSON_UNLIKELY(x)
Definition: json.hpp:194
#define JSON_THROW(exception)
Definition: json.hpp:162
static int p
Definition: ccl_emu17.c:25
static int m[2]
Definition: ccl_emu17.c:25
template<typename BasicJsonType >
void nlohmann::detail::from_json_array_impl ( const BasicJsonType &  j,
typename BasicJsonType::array_t &  arr,
priority_tag< 3 >   
)

Definition at line 1362 of file json.hpp.

Referenced by void().

1363 {
1364  arr = *j.template get_ptr<const typename BasicJsonType::array_t*>();
1365 }
template<typename BasicJsonType , typename T , std::size_t N>
auto nlohmann::detail::from_json_array_impl ( const BasicJsonType &  j,
std::array< T, N > &  arr,
priority_tag< 2 >   
) -> decltype(j.template get<T>(), void())

Definition at line 1368 of file json.hpp.

1371 {
1372  for (std::size_t i = 0; i < N; ++i)
1373  {
1374  arr[i] = j.at(i).template get<T>();
1375  }
1376 }
template<typename BasicJsonType , typename ConstructibleArrayType >
auto nlohmann::detail::from_json_array_impl ( const BasicJsonType &  j,
ConstructibleArrayType &  arr,
priority_tag< 1 >   
) -> decltype( arr.reserve(std::declval<typename ConstructibleArrayType::size_type>()), j.template get<typename ConstructibleArrayType::value_type>(), void())

Definition at line 1379 of file json.hpp.

References Catch::end.

1384 {
1385  using std::end;
1386 
1387  arr.reserve(j.size());
1388  std::transform(j.begin(), j.end(),
1389  std::inserter(arr, end(arr)), [](const BasicJsonType & i)
1390  {
1391  // get<BasicJsonType>() returns *this, this won't call a from_json
1392  // method when value_type is BasicJsonType
1393  return i.template get<typename ConstructibleArrayType::value_type>();
1394  });
1395 }
not_this_one end(...)
template<typename BasicJsonType , typename ConstructibleArrayType >
void nlohmann::detail::from_json_array_impl ( const BasicJsonType &  j,
ConstructibleArrayType &  arr,
priority_tag< 0 >   
)

Definition at line 1398 of file json.hpp.

References Catch::end.

1400 {
1401  using std::end;
1402 
1403  std::transform(
1404  j.begin(), j.end(), std::inserter(arr, end(arr)),
1405  [](const BasicJsonType & i)
1406  {
1407  // get<BasicJsonType>() returns *this, this won't call a from_json
1408  // method when value_type is BasicJsonType
1409  return i.template get<typename ConstructibleArrayType::value_type>();
1410  });
1411 }
not_this_one end(...)
template<typename BasicJsonType , typename Tuple , std::size_t... Idx>
void nlohmann::detail::from_json_tuple_impl ( const BasicJsonType &  j,
Tuple &  t,
index_sequence< Idx... >   
)

Definition at line 1504 of file json.hpp.

Referenced by from_json().

1505 {
1506  t = std::make_tuple(j.at(Idx).template get<typename std::tuple_element<Idx, Tuple>::type>()...);
1507 }
j template nlohmann::detail::get< typename ConstructibleArrayType::value_type > ( )
template<typename BasicJsonType , typename ArithmeticType , enable_if_t< std::is_arithmetic< ArithmeticType >::value andnot std::is_same< ArithmeticType, typename BasicJsonType::boolean_t >::value, int > = 0>
void nlohmann::detail::get_arithmetic_value ( const BasicJsonType &  j,
ArithmeticType &  val 
)

Definition at line 1243 of file json.hpp.

References nlohmann::detail::type_error::create(), JSON_THROW, number_float, number_integer, number_unsigned, and string.

Referenced by from_json().

1244 {
1245  switch (static_cast<value_t>(j))
1246  {
1247  case value_t::number_unsigned:
1248  {
1249  val = static_cast<ArithmeticType>(*j.template get_ptr<const typename BasicJsonType::number_unsigned_t*>());
1250  break;
1251  }
1252  case value_t::number_integer:
1253  {
1254  val = static_cast<ArithmeticType>(*j.template get_ptr<const typename BasicJsonType::number_integer_t*>());
1255  break;
1256  }
1257  case value_t::number_float:
1258  {
1259  val = static_cast<ArithmeticType>(*j.template get_ptr<const typename BasicJsonType::number_float_t*>());
1260  break;
1261  }
1262 
1263  default:
1264  JSON_THROW(type_error::create(302, "type must be number, but is " + std::string(j.type_name())));
1265  }
1266 }
#define JSON_THROW(exception)
Definition: json.hpp:162
bool nlohmann::detail::operator< ( const value_t  lhs,
const value_t  rhs 
)
inlinenoexcept

comparison operator for JSON types

Returns an ordering that is similar to Python:

  • order: null < boolean < number < object < array < string
  • furthermore, each type is not smaller than itself
  • discarded values are not comparable
Since
version 1.0.0

Definition at line 1182 of file json.hpp.

Referenced by std::less< ::nlohmann::detail::value_t >::operator()(), nlohmann::detail::iter_impl< BasicJsonType >::operator>=(), and Catch::SourceLineInfo::SourceLineInfo().

1183 {
1184  static constexpr std::array<std::uint8_t, 8> order = {{
1185  0 /* null */, 3 /* object */, 4 /* array */, 5 /* string */,
1186  1 /* boolean */, 2 /* integer */, 2 /* unsigned */, 2 /* float */
1187  }
1188  };
1189 
1190  const auto l_index = static_cast<std::size_t>(lhs);
1191  const auto r_index = static_cast<std::size_t>(rhs);
1192  return l_index < order.size() and r_index < order.size() and order[l_index] < order[r_index];
1193 }
template<typename FloatType >
char* nlohmann::detail::to_chars ( char *  first,
const char *  last,
FloatType  value 
)

generates a decimal representation of the floating-point number value in [first, last).

The format of the resulting decimal representation is similar to printf's g format. Returns an iterator pointing past-the-end of the decimal representation.

Note
The input number must be finite, i.e. NaN's and Inf's are not supported.
The buffer must be large enough.
The result is NOT null-terminated.

Definition at line 10727 of file json.hpp.

References nlohmann::detail::dtoa_impl::format_buffer(), nlohmann::detail::dtoa_impl::grisu2(), and Catch::Generators::value().

Referenced by nlohmann::detail::serializer< BasicJsonType >::dump_float().

10728 {
10729  static_cast<void>(last); // maybe unused - fix warning
10730  assert(std::isfinite(value));
10731 
10732  // Use signbit(value) instead of (value < 0) since signbit works for -0.
10733  if (std::signbit(value))
10734  {
10735  value = -value;
10736  *first++ = '-';
10737  }
10738 
10739  if (value == 0) // +-0
10740  {
10741  *first++ = '0';
10742  // Make it look like a floating-point number (#362, #378)
10743  *first++ = '.';
10744  *first++ = '0';
10745  return first;
10746  }
10747 
10748  assert(last - first >= std::numeric_limits<FloatType>::max_digits10);
10749 
10750  // Compute v = buffer * 10^decimal_exponent.
10751  // The decimal digits are stored in the buffer, which needs to be interpreted
10752  // as an unsigned decimal integer.
10753  // len is the length of the buffer, i.e. the number of decimal digits.
10754  int len = 0;
10755  int decimal_exponent = 0;
10756  dtoa_impl::grisu2(first, len, decimal_exponent, value);
10757 
10758  assert(len <= std::numeric_limits<FloatType>::max_digits10);
10759 
10760  // Format the buffer like printf("%.*g", prec, value)
10761  constexpr int kMinExp = -4;
10762  // Use digits10 here to increase compatibility with version 2.
10763  constexpr int kMaxExp = std::numeric_limits<FloatType>::digits10;
10764 
10765  assert(last - first >= kMaxExp + 2);
10766  assert(last - first >= 2 + (-kMinExp - 1) + std::numeric_limits<FloatType>::max_digits10);
10767  assert(last - first >= std::numeric_limits<FloatType>::max_digits10 + 6);
10768 
10769  return dtoa_impl::format_buffer(first, len, decimal_exponent, kMinExp, kMaxExp);
10770 }
char * format_buffer(char *buf, int len, int decimal_exponent, int min_exp, int max_exp)
prettify v = buf * 10^decimal_exponent
Definition: json.hpp:10644
auto value(T const &val) -> Generator< T >
Definition: catch.hpp:3177
void grisu2(char *buf, int &len, int &decimal_exponent, FloatType value)
Definition: json.hpp:10556
template<typename BasicJsonType , typename T , enable_if_t< std::is_same< T, typename BasicJsonType::boolean_t >::value, int > = 0>
void nlohmann::detail::to_json ( BasicJsonType &  j,
b 
)
noexcept

Definition at line 1902 of file json.hpp.

Referenced by nlohmann::detail::to_json_fn::operator()().

1903 {
1904  external_constructor<value_t::boolean>::construct(j, b);
1905 }
template<typename BasicJsonType , typename CompatibleString , enable_if_t< std::is_constructible< typename BasicJsonType::string_t, CompatibleString >::value, int > = 0>
void nlohmann::detail::to_json ( BasicJsonType &  j,
const CompatibleString &  s 
)

Definition at line 1909 of file json.hpp.

1910 {
1911  external_constructor<value_t::string>::construct(j, s);
1912 }
template<typename BasicJsonType >
void nlohmann::detail::to_json ( BasicJsonType &  j,
typename BasicJsonType::string_t &&  s 
)

Definition at line 1915 of file json.hpp.

1916 {
1917  external_constructor<value_t::string>::construct(j, std::move(s));
1918 }
template<typename BasicJsonType , typename FloatType , enable_if_t< std::is_floating_point< FloatType >::value, int > = 0>
void nlohmann::detail::to_json ( BasicJsonType &  j,
FloatType  val 
)
noexcept

Definition at line 1922 of file json.hpp.

1923 {
1924  external_constructor<value_t::number_float>::construct(j, static_cast<typename BasicJsonType::number_float_t>(val));
1925 }
template<typename BasicJsonType , typename CompatibleNumberUnsignedType , enable_if_t< is_compatible_integer_type< typename BasicJsonType::number_unsigned_t, CompatibleNumberUnsignedType >::value, int > = 0>
void nlohmann::detail::to_json ( BasicJsonType &  j,
CompatibleNumberUnsignedType  val 
)
noexcept

Definition at line 1929 of file json.hpp.

1930 {
1931  external_constructor<value_t::number_unsigned>::construct(j, static_cast<typename BasicJsonType::number_unsigned_t>(val));
1932 }
template<typename BasicJsonType , typename CompatibleNumberIntegerType , enable_if_t< is_compatible_integer_type< typename BasicJsonType::number_integer_t, CompatibleNumberIntegerType >::value, int > = 0>
void nlohmann::detail::to_json ( BasicJsonType &  j,
CompatibleNumberIntegerType  val 
)
noexcept

Definition at line 1936 of file json.hpp.

1937 {
1938  external_constructor<value_t::number_integer>::construct(j, static_cast<typename BasicJsonType::number_integer_t>(val));
1939 }
template<typename BasicJsonType , typename EnumType , enable_if_t< std::is_enum< EnumType >::value, int > = 0>
void nlohmann::detail::to_json ( BasicJsonType &  j,
EnumType  e 
)
noexcept

Definition at line 1943 of file json.hpp.

1944 {
1945  using underlying_type = typename std::underlying_type<EnumType>::type;
1946  external_constructor<value_t::number_integer>::construct(j, static_cast<underlying_type>(e));
1947 }
template<typename BasicJsonType >
void nlohmann::detail::to_json ( BasicJsonType &  j,
const std::vector< bool > &  e 
)

Definition at line 1950 of file json.hpp.

1951 {
1952  external_constructor<value_t::array>::construct(j, e);
1953 }
template<typename BasicJsonType , typename CompatibleArrayType , enable_if_t< is_compatible_array_type< BasicJsonType, CompatibleArrayType >::value andnot is_compatible_object_type< BasicJsonType, CompatibleArrayType >::value andnot is_compatible_string_type< BasicJsonType, CompatibleArrayType >::value andnot is_basic_json< CompatibleArrayType >::value, int > = 0>
void nlohmann::detail::to_json ( BasicJsonType &  j,
const CompatibleArrayType &  arr 
)

Definition at line 1963 of file json.hpp.

References growth_allz::T.

1964 {
1965  external_constructor<value_t::array>::construct(j, arr);
1966 }
template<typename BasicJsonType , typename T , enable_if_t< std::is_convertible< T, BasicJsonType >::value, int > = 0>
void nlohmann::detail::to_json ( BasicJsonType &  j,
const std::valarray< T > &  arr 
)

Definition at line 1970 of file json.hpp.

1971 {
1972  external_constructor<value_t::array>::construct(j, std::move(arr));
1973 }
template<typename BasicJsonType >
void nlohmann::detail::to_json ( BasicJsonType &  j,
typename BasicJsonType::array_t &&  arr 
)

Definition at line 1976 of file json.hpp.

1977 {
1978  external_constructor<value_t::array>::construct(j, std::move(arr));
1979 }
template<typename BasicJsonType , typename CompatibleObjectType , enable_if_t< is_compatible_object_type< BasicJsonType, CompatibleObjectType >::value and not is_basic_json< CompatibleObjectType >::value, int > = 0>
void nlohmann::detail::to_json ( BasicJsonType &  j,
const CompatibleObjectType &  obj 
)

Definition at line 1983 of file json.hpp.

1984 {
1985  external_constructor<value_t::object>::construct(j, obj);
1986 }
template<typename BasicJsonType >
void nlohmann::detail::to_json ( BasicJsonType &  j,
typename BasicJsonType::object_t &&  obj 
)

Definition at line 1989 of file json.hpp.

References growth_allz::T, and Catch::Generators::value().

1990 {
1991  external_constructor<value_t::object>::construct(j, std::move(obj));
1992 }
template<typename BasicJsonType , typename T , std::size_t N, enable_if_t< not std::is_constructible< typename BasicJsonType::string_t, const T(&)[N]>::value, int > = 0>
void nlohmann::detail::to_json ( BasicJsonType &  j,
const T(&)  arr[N] 
)

Definition at line 1999 of file json.hpp.

2000 {
2001  external_constructor<value_t::array>::construct(j, arr);
2002 }
template<typename BasicJsonType , typename... Args>
void nlohmann::detail::to_json ( BasicJsonType &  j,
const std::pair< Args... > &  p 
)

Definition at line 2005 of file json.hpp.

References growth_allz::T, and Catch::Generators::value().

2006 {
2007  j = {p.first, p.second};
2008 }
static int p
Definition: ccl_emu17.c:25
template<typename BasicJsonType , typename T , enable_if_t< std::is_same< T, typename iteration_proxy< typename BasicJsonType::iterator >::iteration_proxy_internal >::value, int > = 0>
void nlohmann::detail::to_json ( BasicJsonType &  j,
const T &  b 
)

Definition at line 2013 of file json.hpp.

2014 {
2015  j = {{b.key(), b.value()}};
2016 }
template<typename BasicJsonType , typename... Args>
void nlohmann::detail::to_json ( BasicJsonType &  j,
const std::tuple< Args... > &  t 
)

Definition at line 2025 of file json.hpp.

References to_json_tuple_impl().

Referenced by nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer >::basic_json(), and nlohmann::adl_serializer< typename, typename >::to_json().

2026 {
2027  to_json_tuple_impl(j, t, index_sequence_for<Args...> {});
2028 }
void to_json_tuple_impl(BasicJsonType &j, const Tuple &t, index_sequence< Idx... >)
Definition: json.hpp:2019
template<typename BasicJsonType , typename Tuple , std::size_t... Idx>
void nlohmann::detail::to_json_tuple_impl ( BasicJsonType &  j,
const Tuple &  t,
index_sequence< Idx... >   
)

Definition at line 2019 of file json.hpp.

Referenced by to_json().

2020 {
2021  j = {std::get<Idx>(t)...};
2022 }
j template nlohmann::detail::void ( )

Definition at line 1424 of file json.hpp.

References nlohmann::detail::type_error::create(), from_json_array_impl(), JSON_THROW, JSON_UNLIKELY, and string.

Referenced by nlohmann::detail::binary_reader< BasicJsonType, SAX >::binary_reader(), and nlohmann::detail::parser< BasicJsonType >::sax_parse().

1425 {
1426  if (JSON_UNLIKELY(not j.is_array()))
1427  {
1428  JSON_THROW(type_error::create(302, "type must be array, but is " +
1429  std::string(j.type_name())));
1430  }
1431 
1432  from_json_array_impl(j, arr, priority_tag<3> {});
1433 }
#define JSON_UNLIKELY(x)
Definition: json.hpp:194
#define JSON_THROW(exception)
Definition: json.hpp:162
void from_json_array_impl(const BasicJsonType &j, ConstructibleArrayType &arr, priority_tag< 0 >)
Definition: json.hpp:1398