Subscript operators

Synopses

Declared in <nlohmann/ordered_map.hpp>

accesses the element with the given key, inserting a default‐constructed value if it does not exist

T&
operator[](key_type const& key);

accesses the element with the given key

T const&
operator[](key_type const& key) const;

accesses the element with the given key, inserting a default‐constructed value if it does not exist

template<class KeyType>
requires detail::is_usable_as_key_type<key_compare, key_type, KeyType>::value
T&
operator[](KeyType&& key);

accesses the element with the given key

template<class KeyType>
requires detail::is_usable_as_key_type<key_compare, key_type, KeyType>::value
T const&
operator[](KeyType&& key) const;

Exceptions

Name

Thrown on

std::out_of_range

if the container does not have an element with the given key

Return Value

  • reference to the value associated with key

  • const reference to the value associated with key

Parameters

Name

Description

key [in]

key of the element to access

Created with MrDocs