]> git.proxmox.com Git - ceph.git/blob - ceph/src/jaegertracing/opentelemetry-cpp/third_party/nlohmann-json/doc/mkdocs/docs/api/basic_json/count.md
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / jaegertracing / opentelemetry-cpp / third_party / nlohmann-json / doc / mkdocs / docs / api / basic_json / count.md
1 # <small>nlohmann::basic_json::</small>count
2
3 ```cpp
4 template<typename KeyT>
5 size_type count(KeyT&& key) const;
6 ```
7
8 Returns the number of elements with key `key`. If `ObjectType` is the default `std::map` type, the return value will
9 always be `0` (`key` was not found) or `1` (`key` was found).
10
11 ## Template parameters
12
13 `KeyT`
14 : A type for an object key.
15
16 ## Parameters
17
18 `key` (in)
19 : key value of the element to count.
20
21 ## Return value
22
23 Number of elements with key `key`. If the JSON value is not an object, the return value will be `0`.
24
25 ## Exception safety
26
27 Strong exception safety: if an exception occurs, the original value stays intact.
28
29 ## Complexity
30
31 Logarithmic in the size of the JSON object.
32
33 ## Notes
34
35 This method always returns `0` when executed on a JSON type that is not an object.
36
37 ## Examples
38
39 ??? example
40
41 The example shows how `count()` is used.
42
43 ```cpp
44 --8<-- "examples/count.cpp"
45 ```
46
47 Output:
48
49 ```json
50 --8<-- "examples/count.output"
51 ```
52
53 ## Version history
54
55 - Added in version 1.0.0.