|
|
template<template< typename U, typename V, typename...Args > class ObjectType = std::map, template< typename U, typename...Args > class ArrayType = std::vector, class StringType = std::string, class BooleanType = bool, class NumberIntegerType = int64_t, class NumberUnsignedType = uint64_t, class NumberFloatType = double, template< typename U > class AllocatorType = std::allocator>
| void nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType >::erase |
( |
const size_type |
idx | ) |
|
|
inline |
Removes element from a JSON array at the index idx.
- Parameters
-
| [in] | idx | index of the element to remove |
- Exceptions
-
| std::domain_error | when called on a type other than JSON array; example: "cannot use erase() with null" |
| std::out_of_range | when idx >= size(); example: "index out of
range" |
- Complexity
- Linear in distance between idx and the end of the container.
- Example
- The example shows the effect of erase.
8 json j_array = {0, 1, 2, 3, 4, 5}; 14 std::cout << j_array << '\n'; basic_json<> json default JSON class
Output (play with this example online): [0,1,3,4,5]
The example code above can be translated withg++ -std=c++11 -Isrc doc/examples/erase__size_type.cpp -o erase__size_type
- See also
- erase(InteratorType) – removes the element at a given position
-
erase(InteratorType, InteratorType) – removes the elements in the given range
-
erase(const typename object_t::key_type&) – removes the element from an object at the given key
- Since
- version 1.0.0
Definition at line 3852 of file json.hpp.
|