📝 update documentation

parent 5ea15c44
...@@ -6,8 +6,10 @@ reference at(size_type idx); ...@@ -6,8 +6,10 @@ reference at(size_type idx);
const_reference at(size_type idx) const; const_reference at(size_type idx) const;
// (2) // (2)
reference at(const typename object_t::key_type& key); template<typename KeyT>
const_reference at(const typename object_t::key_type& key) const; reference at(KeyT && key);
template<typename KeyT>
const_reference at(KeyT && key) const;
// (3) // (3)
reference at(const json_pointer& ptr); reference at(const json_pointer& ptr);
...@@ -18,6 +20,11 @@ const_reference at(const json_pointer& ptr) const; ...@@ -18,6 +20,11 @@ const_reference at(const json_pointer& ptr) const;
2. Returns a reference to the element at with specified key `key`, with bounds checking. 2. Returns a reference to the element at with specified key `key`, with bounds checking.
3. Returns a reference to the element at with specified JSON pointer `ptr`, with bounds checking. 3. Returns a reference to the element at with specified JSON pointer `ptr`, with bounds checking.
## Template parameters
`KeyT`
: A type convertible to an object key. This can also be a string literal or a string view (C++17).
## Parameters ## Parameters
`idx` (in) `idx` (in)
......
...@@ -11,7 +11,8 @@ value is not an object, `#!cpp false` is returned. ...@@ -11,7 +11,8 @@ value is not an object, `#!cpp false` is returned.
## Template parameters ## Template parameters
`KeyT` `KeyT`
: A type for an object key other than `basic_json::json_pointer`. : A type for an object key other than `basic_json::json_pointer`. This can also be a string literal or a string view
(C++17).
## Parameters ## Parameters
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
```cpp ```cpp
template<typename KeyT> template<typename KeyT>
size_type count(KeyT&& key) const; size_type count(KeyT && key) const;
``` ```
Returns the number of elements with key `key`. If `ObjectType` is the default `std::map` type, the return value will Returns the number of elements with key `key`. If `ObjectType` is the default `std::map` type, the return value will
...@@ -11,7 +11,7 @@ always be `0` (`key` was not found) or `1` (`key` was found). ...@@ -11,7 +11,7 @@ always be `0` (`key` was not found) or `1` (`key` was found).
## Template parameters ## Template parameters
`KeyT` `KeyT`
: A type for an object key. : A type for an object key. This can also be a string literal or a string view (C++17).
## Parameters ## Parameters
......
...@@ -10,7 +10,8 @@ iterator erase(iterator first, iterator last); ...@@ -10,7 +10,8 @@ iterator erase(iterator first, iterator last);
const_iterator erase(const_iterator first, const_iterator last); const_iterator erase(const_iterator first, const_iterator last);
// (3) // (3)
size_type erase(const typename object_t::key_type& key); template<typename KeyT>
size_type erase(KeyT && key);
// (4) // (4)
void erase(const size_type idx); void erase(const size_type idx);
...@@ -31,6 +32,11 @@ void erase(const size_type idx); ...@@ -31,6 +32,11 @@ void erase(const size_type idx);
4. Removes an element from a JSON array by index. 4. Removes an element from a JSON array by index.
## Template parameters
`KeyT`
: A type convertible to an object key. This can also be a string literal or a string view (C++17).
## Parameters ## Parameters
`pos` (in) `pos` (in)
......
...@@ -2,10 +2,10 @@ ...@@ -2,10 +2,10 @@
```cpp ```cpp
template<typename KeyT> template<typename KeyT>
iterator find(KeyT&& key); iterator find(KeyT && key);
template<typename KeyT> template<typename KeyT>
const_iterator find(KeyT&& key) const const_iterator find(KeyT && key) const
``` ```
Finds an element in a JSON object with key equivalent to `key`. If the element is not found or the JSON value is not an Finds an element in a JSON object with key equivalent to `key`. If the element is not found or the JSON value is not an
...@@ -14,7 +14,7 @@ object, `end()` is returned. ...@@ -14,7 +14,7 @@ object, `end()` is returned.
## Template parameters ## Template parameters
`KeyT` `KeyT`
: A type for an object key. : A type for an object key. This can also be a string literal or a string view (C++17).
## Parameters ## Parameters
......
...@@ -6,8 +6,10 @@ reference operator[](size_type idx); ...@@ -6,8 +6,10 @@ reference operator[](size_type idx);
const_reference operator[](size_type idx) const; const_reference operator[](size_type idx) const;
// (2) // (2)
reference operator[](const typename object_t::key_type& key); template<typename KeyT>
const_reference operator[](const typename object_t::key_type& key) const; reference operator[](KeyT && key);
template<typename KeyT>
const_reference operator[](KeyT && key) const;
template<typename T> template<typename T>
reference operator[](T* key); reference operator[](T* key);
template<typename T> template<typename T>
...@@ -24,6 +26,9 @@ const_reference operator[](const json_pointer& ptr) const; ...@@ -24,6 +26,9 @@ const_reference operator[](const json_pointer& ptr) const;
## Template parameters ## Template parameters
`KeyT`
: A type convertible to an object key. This can also be a string literal or a string view (C++17).
`T` `T`
: string literal convertible to `object_t::key_type` : string literal convertible to `object_t::key_type`
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment