📝 make examples collapsible

This commit is contained in:
Niels Lohmann 2020-05-24 22:45:38 +02:00
parent ddf92606ab
commit 95a3c76643
No known key found for this signature in database
GPG key ID: 7F3CEA63AE251B69
14 changed files with 502 additions and 270 deletions

View file

@ -0,0 +1,129 @@
# Iterators
## Overview
A JSON value is a container and allows access via iterators.
![](../images/range-begin-end.svg)
![](../images/range-rbegin-rend.svg)
## Iterator getters
### `begin()`
??? example
The following code shows an example for `begin()`.
```cpp
--8<-- "examples/begin.cpp"
```
Output:
```json
--8<-- "examples/begin.output"
```
### `cbegin()`
??? example
The following code shows an example for `cbegin()`.
```cpp
--8<-- "examples/cbegin.cpp"
```
Output:
```json
--8<-- "examples/cbegin.output"
```
### `end()`
??? example
The following code shows an example for `end()`.
```cpp
--8<-- "examples/end.cpp"
```
Output:
```json
--8<-- "examples/end.output"
```
### `cend()`
??? example
The following code shows an example for `cend()`.
```cpp
--8<-- "examples/cend.cpp"
```
Output:
```json
--8<-- "examples/cend.output"
```
### `rbegin()`
??? example
The following code shows an example for `rbegin()`.
```cpp
--8<-- "examples/rbegin.cpp"
```
Output:
```json
--8<-- "examples/rbegin.output"
```
### `rend()`
??? example
The following code shows an example for `rend()`.
```cpp
--8<-- "examples/rend.cpp"
```
Output:
```json
--8<-- "examples/rend.output"
```
### `items()`
??? example
The following code shows an example for `items()`.
```cpp
--8<-- "examples/items.cpp"
```
Output:
```
--8<-- "examples/items.output"
```
## Iterator invalidation
| Operations | invalidated iterators |
| ---------- | --------------------- |
| `clear` | all |