nlohmann::detail::invalid_iterator Class Reference

exception indicating errors with iterators More...

`#include <json.hpp>`

Inheritance diagram for nlohmann::detail::invalid_iterator:
Collaboration diagram for nlohmann::detail::invalid_iterator:

## Static Public Member Functions

template<typename BasicJsonType >
static invalid_iterator | create (int id_, const std::string &what_arg, const BasicJsonType &context)

## Private Member Functions

| invalid_iterator (int id_, const char *what_arg)

## Additional Inherited Members

Public Member Functions inherited from nlohmann::detail::exception
const char * | what () const noexcept override
| returns the explanatory string More...
Public Attributes inherited from nlohmann::detail::exception
const int | id
| the id of the exception More...
Protected Member Functions inherited from nlohmann::detail::exception
| exception (int id_, const char *what_arg)
Static Protected Member Functions inherited from nlohmann::detail::exception
static std::string | name (const std::string &ename, int id_)
template<typename BasicJsonType >
static std::string | diagnostics (const BasicJsonType &leaf_element)

## Detailed Description

exception indicating errors with iterators

This exception is thrown if iterators passed to a library function do not match the expected semantics.

Exceptions have ids 2xx.

name / id | example message | description
--- | --- | ---
json.exception.invalid_iterator.201 | iterators are not compatible | The iterators passed to constructor basic_json(InputIT first, InputIT last) are not compatible, meaning they do not belong to the same container. Therefore, the range (first, last) is invalid.
json.exception.invalid_iterator.202 | iterator does not fit current value | In an erase or insert function, the passed iterator pos does not belong to the JSON value for which the function was called. It hence does not define a valid position for the deletion/insertion.
json.exception.invalid_iterator.203 | iterators do not fit current value | Either iterator passed to function erase(IteratorType first, IteratorType last) does not belong to the JSON value from which values shall be erased. It hence does not define a valid range to delete values from.
json.exception.invalid_iterator.204 | iterators out of range | When an iterator range for a primitive type (number, boolean, or string) is passed to a constructor or an erase function, this range has to be exactly (begin(), end()), because this is the only way the single stored value is expressed. All other ranges are invalid.
json.exception.invalid_iterator.205 | iterator out of range | When an iterator for a primitive type (number, boolean, or string) is passed to an erase function, the iterator has to be the begin() iterator, because it is the only way to address the stored value. All other iterators are invalid.
json.exception.invalid_iterator.206 | cannot construct with iterators from null | The iterators passed to constructor basic_json(InputIT first, InputIT last) belong to a JSON null value and hence to not define a valid range.
json.exception.invalid_iterator.207 | cannot use key() for non-object iterators | The key() member function can only be used on iterators belonging to a JSON object, because other types do not have a concept of a key.
json.exception.invalid_iterator.208 | cannot use operator[] for object iterators | The operator[] to specify a concrete offset cannot be used on iterators belonging to a JSON object, because JSON objects are unordered.
json.exception.invalid_iterator.209 | cannot use offsets with object iterators | The offset operators (+, -, +=, -=) cannot be used on iterators belonging to a JSON object, because JSON objects are unordered.
json.exception.invalid_iterator.210 | iterators do not fit | The iterator range passed to the insert function are not compatible, meaning they do not belong to the same container. Therefore, the range (first, last) is invalid.
json.exception.invalid_iterator.211 | passed iterators may not belong to container | The iterator range passed to the insert function must not be a subrange of the container to insert to.
json.exception.invalid_iterator.212 | cannot compare iterators of different containers | When two iterators are compared, they must belong to the same container.
json.exception.invalid_iterator.213 | cannot compare order of object iterators | The order of object iterators cannot be compared, because JSON objects are unordered.
json.exception.invalid_iterator.214 | cannot get value | Cannot get value for iterator: Either the iterator belongs to a null value or it is an iterator to a primitive type (number, boolean, or string), but the iterator is different to begin().

{The following code shows how an `invalid_iterator` exception can be caught.,invalid_iterator}

See also
  - exception for the base class of the library exceptions
  - parse_error for exceptions indicating a parse error
  - type_error for exceptions indicating executing a member function with a wrong type
  - out_of_range for exceptions indicating access out of the defined range
  - other_error for exceptions indicating other library errors

Since
  version 3.0.0

Definition at line 2857 of file json.hpp.

## Constructor & Destructor Documentation

## invalid_iterator()

nlohmann::detail::invalid_iterator::invalid_iterator | ( | int | id_,
|  | const char * | what_arg
| ) |  |

inlineprivate

Definition at line 2869 of file json.hpp.

## Member Function Documentation

## create()

template<typename BasicJsonType >

static invalid_iterator nlohmann::detail::invalid_iterator::create | ( | int | id_,
|  | const std::string & | what_arg,
|  | const BasicJsonType & | context
| ) |  |

inlinestatic

Definition at line 2861 of file json.hpp.

References nlohmann::detail::exception::diagnostics(), JSON_HEDLEY_NON_NULL, nlohmann::detail::exception::name(), and nlohmann::detail::string.

Referenced by nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType >::basic_json(), nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType >::erase(), nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType >::insert(), nlohmann::detail::iter_impl< BasicJsonType >::key(), nlohmann::detail::iter_impl< BasicJsonType >::operator*(), nlohmann::detail::iter_impl< BasicJsonType >::operator+=(), nlohmann::detail::iter_impl< BasicJsonType >::operator-(), nlohmann::detail::iter_impl< BasicJsonType >::operator->(), nlohmann::detail::iter_impl< BasicJsonType >::operator<(), nlohmann::detail::iter_impl< BasicJsonType >::operator==(), nlohmann::detail::iter_impl< BasicJsonType >::operator[](), and nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType >::update().

The documentation for this class was generated from the following file:

- json.hpp