👌 address review comments
This commit is contained in:
parent
5379b5d091
commit
15e45981ea
@ -7,9 +7,9 @@ const_reference operator[](size_type idx) const;
|
|||||||
|
|
||||||
// (2)
|
// (2)
|
||||||
template<typename KeyT>
|
template<typename KeyT>
|
||||||
reference operator[](KeyT && key);
|
reference operator[](const KeyT& key);
|
||||||
template<typename KeyT>
|
template<typename KeyT>
|
||||||
const_reference operator[](KeyT && key) const;
|
const_reference operator[](const KeyT& key) const;
|
||||||
|
|
||||||
// (3)
|
// (3)
|
||||||
reference operator[](const json_pointer& ptr);
|
reference operator[](const json_pointer& ptr);
|
||||||
|
|||||||
@ -3750,7 +3750,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
|||||||
*/
|
*/
|
||||||
template < class KeyT, typename detail::enable_if_t <
|
template < class KeyT, typename detail::enable_if_t <
|
||||||
detail::is_usable_as_key_type<basic_json_t, KeyT>::value&& !std::is_same<typename std::decay<KeyT>::type, json_pointer>::value, int > = 0 >
|
detail::is_usable_as_key_type<basic_json_t, KeyT>::value&& !std::is_same<typename std::decay<KeyT>::type, json_pointer>::value, int > = 0 >
|
||||||
reference operator[](KeyT && key)
|
reference operator[](const KeyT& key)
|
||||||
{
|
{
|
||||||
// implicitly convert null value to an empty object
|
// implicitly convert null value to an empty object
|
||||||
if (is_null())
|
if (is_null())
|
||||||
@ -3763,7 +3763,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
|||||||
// operator[] only works for objects
|
// operator[] only works for objects
|
||||||
if (JSON_HEDLEY_LIKELY(is_object()))
|
if (JSON_HEDLEY_LIKELY(is_object()))
|
||||||
{
|
{
|
||||||
auto result = m_value.object->emplace(std::forward<KeyT>(key), nullptr);
|
auto result = m_value.object->emplace(key, nullptr);
|
||||||
return set_parent(result.first->second);
|
return set_parent(result.first->second);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3803,12 +3803,12 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
|||||||
*/
|
*/
|
||||||
template < class KeyT, typename detail::enable_if_t <
|
template < class KeyT, typename detail::enable_if_t <
|
||||||
detail::is_usable_as_key_type<basic_json_t, KeyT>::value&& !std::is_same<typename std::decay<KeyT>::type, json_pointer>::value, int > = 0 >
|
detail::is_usable_as_key_type<basic_json_t, KeyT>::value&& !std::is_same<typename std::decay<KeyT>::type, json_pointer>::value, int > = 0 >
|
||||||
const_reference operator[](KeyT && key) const
|
const_reference operator[](const KeyT& key) const
|
||||||
{
|
{
|
||||||
// operator[] only works for objects
|
// operator[] only works for objects
|
||||||
if (JSON_HEDLEY_LIKELY(is_object()))
|
if (JSON_HEDLEY_LIKELY(is_object()))
|
||||||
{
|
{
|
||||||
auto it = m_value.object->find(std::forward<KeyT>(key));
|
auto it = m_value.object->find(key);
|
||||||
JSON_ASSERT(it != m_value.object->end());
|
JSON_ASSERT(it != m_value.object->end());
|
||||||
return it->second;
|
return it->second;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -21317,7 +21317,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
|||||||
*/
|
*/
|
||||||
template < class KeyT, typename detail::enable_if_t <
|
template < class KeyT, typename detail::enable_if_t <
|
||||||
detail::is_usable_as_key_type<basic_json_t, KeyT>::value&& !std::is_same<typename std::decay<KeyT>::type, json_pointer>::value, int > = 0 >
|
detail::is_usable_as_key_type<basic_json_t, KeyT>::value&& !std::is_same<typename std::decay<KeyT>::type, json_pointer>::value, int > = 0 >
|
||||||
reference operator[](KeyT && key)
|
reference operator[](const KeyT& key)
|
||||||
{
|
{
|
||||||
// implicitly convert null value to an empty object
|
// implicitly convert null value to an empty object
|
||||||
if (is_null())
|
if (is_null())
|
||||||
@ -21330,7 +21330,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
|||||||
// operator[] only works for objects
|
// operator[] only works for objects
|
||||||
if (JSON_HEDLEY_LIKELY(is_object()))
|
if (JSON_HEDLEY_LIKELY(is_object()))
|
||||||
{
|
{
|
||||||
auto result = m_value.object->emplace(std::forward<KeyT>(key), nullptr);
|
auto result = m_value.object->emplace(key, nullptr);
|
||||||
return set_parent(result.first->second);
|
return set_parent(result.first->second);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -21370,12 +21370,12 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
|||||||
*/
|
*/
|
||||||
template < class KeyT, typename detail::enable_if_t <
|
template < class KeyT, typename detail::enable_if_t <
|
||||||
detail::is_usable_as_key_type<basic_json_t, KeyT>::value&& !std::is_same<typename std::decay<KeyT>::type, json_pointer>::value, int > = 0 >
|
detail::is_usable_as_key_type<basic_json_t, KeyT>::value&& !std::is_same<typename std::decay<KeyT>::type, json_pointer>::value, int > = 0 >
|
||||||
const_reference operator[](KeyT && key) const
|
const_reference operator[](const KeyT& key) const
|
||||||
{
|
{
|
||||||
// operator[] only works for objects
|
// operator[] only works for objects
|
||||||
if (JSON_HEDLEY_LIKELY(is_object()))
|
if (JSON_HEDLEY_LIKELY(is_object()))
|
||||||
{
|
{
|
||||||
auto it = m_value.object->find(std::forward<KeyT>(key));
|
auto it = m_value.object->find(key);
|
||||||
JSON_ASSERT(it != m_value.object->end());
|
JSON_ASSERT(it != m_value.object->end());
|
||||||
return it->second;
|
return it->second;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user