mirror of
https://github.com/nlohmann/json.git
synced 2024-08-22 21:12:27 +02:00
Merge branch 'feature/undo_171' into develop
This commit is contained in:
commit
e67df7c385
68
src/json.hpp
68
src/json.hpp
|
@ -4240,74 +4240,6 @@ class basic_json
|
||||||
with range checking
|
with range checking
|
||||||
@sa @ref value() for access by value with a default value
|
@sa @ref value() for access by value with a default value
|
||||||
|
|
||||||
@since version 1.0.0
|
|
||||||
*/
|
|
||||||
template<typename T, std::size_t n>
|
|
||||||
reference operator[](T * (&key)[n])
|
|
||||||
{
|
|
||||||
return operator[](static_cast<const T>(key));
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
|
||||||
@brief read-only access specified object element
|
|
||||||
|
|
||||||
Returns a const reference to the element at with specified key @a key. No
|
|
||||||
bounds checking is performed.
|
|
||||||
|
|
||||||
@warning If the element with key @a key does not exist, the behavior is
|
|
||||||
undefined.
|
|
||||||
|
|
||||||
@note This function is required for compatibility reasons with Clang.
|
|
||||||
|
|
||||||
@param[in] key key of the element to access
|
|
||||||
|
|
||||||
@return const reference to the element at key @a key
|
|
||||||
|
|
||||||
@throw type_error.305 if the JSON value is not an object; in that cases,
|
|
||||||
using the [] operator with a key makes no sense.
|
|
||||||
|
|
||||||
@complexity Logarithmic in the size of the container.
|
|
||||||
|
|
||||||
@liveexample{The example below shows how object elements can be read using
|
|
||||||
the `[]` operator.,operatorarray__key_type_const}
|
|
||||||
|
|
||||||
@sa @ref at(const typename object_t::key_type&) for access by reference
|
|
||||||
with range checking
|
|
||||||
@sa @ref value() for access by value with a default value
|
|
||||||
|
|
||||||
@since version 1.0.0
|
|
||||||
*/
|
|
||||||
template<typename T, std::size_t n>
|
|
||||||
const_reference operator[](T * (&key)[n]) const
|
|
||||||
{
|
|
||||||
return operator[](static_cast<const T>(key));
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
|
||||||
@brief access specified object element
|
|
||||||
|
|
||||||
Returns a reference to the element at with specified key @a key.
|
|
||||||
|
|
||||||
@note If @a key is not found in the object, then it is silently added to
|
|
||||||
the object and filled with a `null` value to make `key` a valid reference.
|
|
||||||
In case the value was `null` before, it is converted to an object.
|
|
||||||
|
|
||||||
@param[in] key key of the element to access
|
|
||||||
|
|
||||||
@return reference to the element at key @a key
|
|
||||||
|
|
||||||
@throw type_error.305 if the JSON value is not an object or null; in that
|
|
||||||
cases, using the [] operator with a key makes no sense.
|
|
||||||
|
|
||||||
@complexity Logarithmic in the size of the container.
|
|
||||||
|
|
||||||
@liveexample{The example below shows how object elements can be read and
|
|
||||||
written using the `[]` operator.,operatorarray__key_type}
|
|
||||||
|
|
||||||
@sa @ref at(const typename object_t::key_type&) for access by reference
|
|
||||||
with range checking
|
|
||||||
@sa @ref value() for access by value with a default value
|
|
||||||
|
|
||||||
@since version 1.1.0
|
@since version 1.1.0
|
||||||
*/
|
*/
|
||||||
template<typename T>
|
template<typename T>
|
||||||
|
|
Loading…
Reference in a new issue