From ba97e9f45d60933a08477f95550f6c9ead4ff6d7 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Thu, 25 Mar 2021 12:54:20 +0100 Subject: [PATCH] :memo: update documentation --- doc/mkdocs/docs/api/basic_json/at.md | 11 +++++++++-- doc/mkdocs/docs/api/basic_json/contains.md | 3 ++- doc/mkdocs/docs/api/basic_json/count.md | 4 ++-- doc/mkdocs/docs/api/basic_json/erase.md | 8 +++++++- doc/mkdocs/docs/api/basic_json/find.md | 6 +++--- doc/mkdocs/docs/api/basic_json/operator[].md | 9 +++++++-- 6 files changed, 30 insertions(+), 11 deletions(-) diff --git a/doc/mkdocs/docs/api/basic_json/at.md b/doc/mkdocs/docs/api/basic_json/at.md index 75977b180..436d98f65 100644 --- a/doc/mkdocs/docs/api/basic_json/at.md +++ b/doc/mkdocs/docs/api/basic_json/at.md @@ -6,8 +6,10 @@ reference at(size_type idx); const_reference at(size_type idx) const; // (2) -reference at(const typename object_t::key_type& key); -const_reference at(const typename object_t::key_type& key) const; +template +reference at(KeyT && key); +template +const_reference at(KeyT && key) const; // (3) reference at(const json_pointer& ptr); @@ -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. 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 `idx` (in) diff --git a/doc/mkdocs/docs/api/basic_json/contains.md b/doc/mkdocs/docs/api/basic_json/contains.md index 1616f0c2d..7f9326864 100644 --- a/doc/mkdocs/docs/api/basic_json/contains.md +++ b/doc/mkdocs/docs/api/basic_json/contains.md @@ -11,7 +11,8 @@ value is not an object, `#!cpp false` is returned. ## Template parameters `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 diff --git a/doc/mkdocs/docs/api/basic_json/count.md b/doc/mkdocs/docs/api/basic_json/count.md index 34f1605d3..f6875faf5 100644 --- a/doc/mkdocs/docs/api/basic_json/count.md +++ b/doc/mkdocs/docs/api/basic_json/count.md @@ -2,7 +2,7 @@ ```cpp template -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 @@ -11,7 +11,7 @@ always be `0` (`key` was not found) or `1` (`key` was found). ## Template parameters `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 diff --git a/doc/mkdocs/docs/api/basic_json/erase.md b/doc/mkdocs/docs/api/basic_json/erase.md index 3d80f5bfd..43cde6dcc 100644 --- a/doc/mkdocs/docs/api/basic_json/erase.md +++ b/doc/mkdocs/docs/api/basic_json/erase.md @@ -10,7 +10,8 @@ iterator erase(iterator first, iterator last); const_iterator erase(const_iterator first, const_iterator last); // (3) -size_type erase(const typename object_t::key_type& key); +template +size_type erase(KeyT && key); // (4) 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. +## Template parameters + +`KeyT` +: A type convertible to an object key. This can also be a string literal or a string view (C++17). + ## Parameters `pos` (in) diff --git a/doc/mkdocs/docs/api/basic_json/find.md b/doc/mkdocs/docs/api/basic_json/find.md index 5ff4baf61..c83648cb0 100644 --- a/doc/mkdocs/docs/api/basic_json/find.md +++ b/doc/mkdocs/docs/api/basic_json/find.md @@ -2,10 +2,10 @@ ```cpp template -iterator find(KeyT&& key); +iterator find(KeyT && key); template -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 @@ -14,7 +14,7 @@ object, `end()` is returned. ## Template parameters `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 diff --git a/doc/mkdocs/docs/api/basic_json/operator[].md b/doc/mkdocs/docs/api/basic_json/operator[].md index 4b36f1a91..6c7645e49 100644 --- a/doc/mkdocs/docs/api/basic_json/operator[].md +++ b/doc/mkdocs/docs/api/basic_json/operator[].md @@ -6,8 +6,10 @@ reference operator[](size_type idx); const_reference operator[](size_type idx) const; // (2) -reference operator[](const typename object_t::key_type& key); -const_reference operator[](const typename object_t::key_type& key) const; +template +reference operator[](KeyT && key); +template +const_reference operator[](KeyT && key) const; template reference operator[](T* key); template @@ -24,6 +26,9 @@ const_reference operator[](const json_pointer& ptr) const; ## Template parameters +`KeyT` +: A type convertible to an object key. This can also be a string literal or a string view (C++17). + `T` : string literal convertible to `object_t::key_type`