WPILibC++ 2025.2.1
Loading...
Searching...
No Matches
wpi::StringMap< T, Allocator > Class Template Reference

StringMap is a sorted associative container that contains key-value pairs with unique string keys. More...

#include <wpi/StringMap.h>

Inheritance diagram for wpi::StringMap< T, Allocator >:

Public Types

using map_type = typename std::map<std::string, T, std::less<>>
 
using key_type = typename map_type::key_type
 
using mapped_type = typename map_type::mapped_type
 
using value_type = typename map_type::value_type
 
using size_type = typename map_type::size_type
 
using difference_type = typename map_type::difference_type
 
using key_compare = typename map_type::key_compare
 
using allocator_type = typename map_type::allocator_type
 
using reference = typename map_type::reference
 
using const_reference = typename map_type::const_reference
 
using pointer = typename map_type::pointer
 
using const_pointer = typename map_type::const_pointer
 
using iterator = typename map_type::iterator
 
using const_iterator = typename map_type::const_iterator
 
using reverse_iterator = typename map_type::reverse_iterator
 
using const_reverse_iterator = typename map_type::const_reverse_iterator
 
using node_type = typename map_type::node_type
 
using insert_return_type = typename map_type::insert_return_type
 

Public Member Functions

 StringMap ()=default
 Constructs an empty container.
 
 StringMap (const Allocator &alloc)
 Constructs an empty container.
 
template<typename InputIt >
 StringMap (InputIt first, InputIt last, const Allocator &alloc=Allocator())
 Constructs the container with the contents of the range [first, last).
 
 StringMap (const StringMap &)=default
 Copy constructor.
 
 StringMap (const StringMap &other, const Allocator &alloc)
 Copy constructor.
 
 StringMap (StringMap &&)=default
 Move constructor.
 
 StringMap (StringMap &&other, const Allocator &alloc)
 Move constructor.
 
 StringMap (std::initializer_list< value_type > init, const Allocator &alloc=Allocator())
 Initializer-list constructor.
 
StringMapoperator= (const StringMap &)=default
 Copy assignment operator.
 
StringMapoperator= (StringMap &&) noexcept(std::allocator_traits< Allocator >::is_always_equal::value &&std::is_nothrow_move_assignable< std::less<> >::value)=default
 Move assignment operator.
 
StringMapoperator= (std::initializer_list< value_type > ilist)
 Replaces the contents with those identified by initializer list ilist.
 
T & at (const std::string &key)
 Returns a reference to the mapped value of the element with the specified key.
 
const T & at (const std::string &key) const
 Returns a reference to the mapped value of the element with the specified key.
 
T & at (const char *key)
 Returns a reference to the mapped value of the element with the specified key.
 
const T & at (const char *key) const
 Returns a reference to the mapped value of the element with the specified key.
 
T & at (std::string_view key)
 Returns a reference to the mapped value of the element with the specified key.
 
const T & at (std::string_view key) const
 Returns a reference to the mapped value of the element with the specified key.
 
T & operator[] (const std::string &key)
 Returns a reference to the value that is mapped to a key, performing an insertion if such a key does not exist.
 
T & operator[] (std::string &&key)
 Returns a reference to the value that is mapped to a key, performing an insertion if such a key does not exist.
 
T & operator[] (const char *key)
 Returns a reference to the value that is mapped to a key, performing an insertion if such a key does not exist.
 
T & operator[] (std::string_view key)
 Returns a reference to the value that is mapped to a key, performing an insertion if such a key does not exist.
 
template<typename M >
std::pair< iterator, bool > insert_or_assign (std::string &&key, M &&obj)
 If a key equal to key already exists in the container, assigns obj to the mapped type corresponding to that key.
 
template<typename M >
std::pair< iterator, bool > insert_or_assign (const char *key, M &&obj)
 If a key equal to key already exists in the container, assigns obj to the mapped type corresponding to that key.
 
template<typename M >
std::pair< iterator, bool > insert_or_assign (std::string_view key, M &&obj)
 If a key equal to key already exists in the container, assigns obj to the mapped type corresponding to that key.
 
template<typename M >
iterator insert_or_assign (const_iterator hint, std::string &&key, M &&obj)
 If a key equal to key already exists in the container, assigns obj to the mapped type corresponding to that key.
 
template<typename M >
iterator insert_or_assign (const_iterator hint, const char *key, M &&obj)
 If a key equal to key already exists in the container, assigns obj to the mapped type corresponding to that key.
 
template<typename M >
iterator insert_or_assign (const_iterator hint, std::string_view key, M &&obj)
 If a key equal to key already exists in the container, assigns obj to the mapped type corresponding to that key.
 
template<typename... Args>
std::pair< iterator, bool > emplace (std::string &&key, Args &&... args)
 Inserts a new element into the container constructed in-place with the given args, if there is no element with the key in the container.
 
template<typename... Args>
std::pair< iterator, bool > emplace (const char *key, Args &&... args)
 Inserts a new element into the container constructed in-place with the given args, if there is no element with the key in the container.
 
template<typename... Args>
std::pair< iterator, bool > emplace (std::string_view key, Args &&... args)
 Inserts a new element into the container constructed in-place with the given args, if there is no element with the key in the container.
 
template<typename... Args>
std::pair< iterator, bool > try_emplace (std::string &&key, Args &&... args)
 If a key equal to key already exists in the container, does nothing.
 
template<typename... Args>
std::pair< iterator, bool > try_emplace (const char *key, Args &&... args)
 If a key equal to key already exists in the container, does nothing.
 
template<typename... Args>
std::pair< iterator, bool > try_emplace (std::string_view key, Args &&... args)
 If a key equal to key already exists in the container, does nothing.
 
template<typename... Args>
iterator try_emplace (const_iterator hint, std::string &&key, Args &&... args)
 If a key equal to key already exists in the container, does nothing.
 
template<typename... Args>
iterator try_emplace (const_iterator hint, const char *key, Args &&... args)
 If a key equal to key already exists in the container, does nothing.
 
template<typename... Args>
iterator try_emplace (const_iterator hint, std::string_view key, Args &&... args)
 If a key equal to key already exists in the container, does nothing.
 
iterator erase (iterator pos)
 Removes the element at pos.
 
iterator erase (const_iterator pos)
 Removes the element at pos.
 
iterator erase (iterator first, iterator last)
 Removes the elements in the range [first, last), which must be a valid range in this.
 
iterator erase (const_iterator first, const_iterator last)
 Removes the elements in the range [first, last), which must be a valid range in this.
 
size_type erase (std::string_view key)
 Removes the element (if one exists) with the key equal to key.
 
void swap (StringMap &other) noexcept(std::allocator_traits< Allocator >::is_always_equal::value &&std::is_nothrow_swappable< std::less<> >::value)
 Exchanges the contents of the container with those of other.
 
node_type extract (const_iterator position)
 Unlinks the node that contains the element pointed to by position and returns a node handle that owns it.
 
node_type extract (std::string_view key)
 If the container has an element with key equal to key, unlinks the node that contains that element from the container and returns a node handle that owns it.
 
size_type count (std::string_view key) const
 Returns the number of elements with key that equals the specified argument.
 
iterator find (std::string_view key)
 Finds an element with key equal to key.
 
const_iterator find (std::string_view key) const
 Finds an element with key equal to key.
 
bool contains (std::string_view key) const
 Checks if there is an element with key equal to key in the container.
 
std::pair< iterator, iteratorequal_range (std::string_view key)
 Returns a range containing all elements with the given key in the container.
 
std::pair< const_iterator, const_iteratorequal_range (std::string_view key) const
 Returns a range containing all elements with the given key in the container.
 
iterator lower_bound (std::string_view key)
 Returns an iterator pointing to the first element that is not less than (i.e.
 
const_iterator lower_bound (std::string_view key) const
 Returns an iterator pointing to the first element that is not less than (i.e.
 
iterator upper_bound (std::string_view key)
 Returns an interator pointing to the first element that is greater than key.
 
const_iterator upper_bound (std::string_view key) const
 Returns an interator pointing to the first element that is greater than key.
 

Detailed Description

template<typename T, typename Allocator = std::allocator<std::pair<const std::string, T>>>
class wpi::StringMap< T, Allocator >

StringMap is a sorted associative container that contains key-value pairs with unique string keys.

Keys are sorted in the same order as std::string's are compared. Search, removal, and insertion operations have logarithmic complexity. The underlying implementation is std::map<std::string, T>.

Member Typedef Documentation

◆ allocator_type

template<typename T , typename Allocator = std::allocator<std::pair<const std::string, T>>>
using wpi::StringMap< T, Allocator >::allocator_type = typename map_type::allocator_type

◆ const_iterator

template<typename T , typename Allocator = std::allocator<std::pair<const std::string, T>>>
using wpi::StringMap< T, Allocator >::const_iterator = typename map_type::const_iterator

◆ const_pointer

template<typename T , typename Allocator = std::allocator<std::pair<const std::string, T>>>
using wpi::StringMap< T, Allocator >::const_pointer = typename map_type::const_pointer

◆ const_reference

template<typename T , typename Allocator = std::allocator<std::pair<const std::string, T>>>
using wpi::StringMap< T, Allocator >::const_reference = typename map_type::const_reference

◆ const_reverse_iterator

template<typename T , typename Allocator = std::allocator<std::pair<const std::string, T>>>
using wpi::StringMap< T, Allocator >::const_reverse_iterator = typename map_type::const_reverse_iterator

◆ difference_type

template<typename T , typename Allocator = std::allocator<std::pair<const std::string, T>>>
using wpi::StringMap< T, Allocator >::difference_type = typename map_type::difference_type

◆ insert_return_type

template<typename T , typename Allocator = std::allocator<std::pair<const std::string, T>>>
using wpi::StringMap< T, Allocator >::insert_return_type = typename map_type::insert_return_type

◆ iterator

template<typename T , typename Allocator = std::allocator<std::pair<const std::string, T>>>
using wpi::StringMap< T, Allocator >::iterator = typename map_type::iterator

◆ key_compare

template<typename T , typename Allocator = std::allocator<std::pair<const std::string, T>>>
using wpi::StringMap< T, Allocator >::key_compare = typename map_type::key_compare

◆ key_type

template<typename T , typename Allocator = std::allocator<std::pair<const std::string, T>>>
using wpi::StringMap< T, Allocator >::key_type = typename map_type::key_type

◆ map_type

template<typename T , typename Allocator = std::allocator<std::pair<const std::string, T>>>
using wpi::StringMap< T, Allocator >::map_type = typename std::map<std::string, T, std::less<>>

◆ mapped_type

template<typename T , typename Allocator = std::allocator<std::pair<const std::string, T>>>
using wpi::StringMap< T, Allocator >::mapped_type = typename map_type::mapped_type

◆ node_type

template<typename T , typename Allocator = std::allocator<std::pair<const std::string, T>>>
using wpi::StringMap< T, Allocator >::node_type = typename map_type::node_type

◆ pointer

template<typename T , typename Allocator = std::allocator<std::pair<const std::string, T>>>
using wpi::StringMap< T, Allocator >::pointer = typename map_type::pointer

◆ reference

template<typename T , typename Allocator = std::allocator<std::pair<const std::string, T>>>
using wpi::StringMap< T, Allocator >::reference = typename map_type::reference

◆ reverse_iterator

template<typename T , typename Allocator = std::allocator<std::pair<const std::string, T>>>
using wpi::StringMap< T, Allocator >::reverse_iterator = typename map_type::reverse_iterator

◆ size_type

template<typename T , typename Allocator = std::allocator<std::pair<const std::string, T>>>
using wpi::StringMap< T, Allocator >::size_type = typename map_type::size_type

◆ value_type

template<typename T , typename Allocator = std::allocator<std::pair<const std::string, T>>>
using wpi::StringMap< T, Allocator >::value_type = typename map_type::value_type

Constructor & Destructor Documentation

◆ StringMap() [1/8]

template<typename T , typename Allocator = std::allocator<std::pair<const std::string, T>>>
wpi::StringMap< T, Allocator >::StringMap ( )
default

Constructs an empty container.

◆ StringMap() [2/8]

template<typename T , typename Allocator = std::allocator<std::pair<const std::string, T>>>
wpi::StringMap< T, Allocator >::StringMap ( const Allocator & alloc)
inlineexplicit

Constructs an empty container.

Parameters
allocallocator to use for all memory allocations of this container

◆ StringMap() [3/8]

template<typename T , typename Allocator = std::allocator<std::pair<const std::string, T>>>
template<typename InputIt >
wpi::StringMap< T, Allocator >::StringMap ( InputIt first,
InputIt last,
const Allocator & alloc = Allocator() )
inline

Constructs the container with the contents of the range [first, last).

If multiple elements in the range have keys that compare equivalent, it is unspecified which element is inserted. If [first, last) is not a valid range, the behavior is undefined.

Parameters
firststart of the range to copy the elements from
lastend of the range to copy the elements from
allocallocator to use for all memory allocations of this container

◆ StringMap() [4/8]

template<typename T , typename Allocator = std::allocator<std::pair<const std::string, T>>>
wpi::StringMap< T, Allocator >::StringMap ( const StringMap< T, Allocator > & )
default

Copy constructor.

◆ StringMap() [5/8]

template<typename T , typename Allocator = std::allocator<std::pair<const std::string, T>>>
wpi::StringMap< T, Allocator >::StringMap ( const StringMap< T, Allocator > & other,
const Allocator & alloc )
inline

Copy constructor.

Parameters
otheranother container to be used as source to initialize the elements of the container with
allocallocator to use for all memory allocations of this container

◆ StringMap() [6/8]

template<typename T , typename Allocator = std::allocator<std::pair<const std::string, T>>>
wpi::StringMap< T, Allocator >::StringMap ( StringMap< T, Allocator > && )
default

Move constructor.

◆ StringMap() [7/8]

template<typename T , typename Allocator = std::allocator<std::pair<const std::string, T>>>
wpi::StringMap< T, Allocator >::StringMap ( StringMap< T, Allocator > && other,
const Allocator & alloc )
inline

Move constructor.

Parameters
otheranother container to be used as source to initialize the elements of the container with
allocallocator to use for all memory allocations of this container

◆ StringMap() [8/8]

template<typename T , typename Allocator = std::allocator<std::pair<const std::string, T>>>
wpi::StringMap< T, Allocator >::StringMap ( std::initializer_list< value_type > init,
const Allocator & alloc = Allocator() )
inline

Initializer-list constructor.

Construct the container with the contents of the initializer list init. If multiple elements in the range have keys that compare equal, it is unspecified which element is inserted.

Parameters
initinitializer list to initialize the elements of the container with
allocallocator to use for all memory allocations of this container

Member Function Documentation

◆ at() [1/6]

template<typename T , typename Allocator = std::allocator<std::pair<const std::string, T>>>
T & wpi::StringMap< T, Allocator >::at ( const char * key)
inline

Returns a reference to the mapped value of the element with the specified key.

If no such element exists, an exception of type std::out_of_range is thrown.

Parameters
keythe key of the element to find
Returns
A reference to the mapped value of the requested element.

◆ at() [2/6]

template<typename T , typename Allocator = std::allocator<std::pair<const std::string, T>>>
const T & wpi::StringMap< T, Allocator >::at ( const char * key) const
inline

Returns a reference to the mapped value of the element with the specified key.

If no such element exists, an exception of type std::out_of_range is thrown.

Parameters
keythe key of the element to find
Returns
A reference to the mapped value of the requested element.

◆ at() [3/6]

template<typename T , typename Allocator = std::allocator<std::pair<const std::string, T>>>
T & wpi::StringMap< T, Allocator >::at ( const std::string & key)
inline

Returns a reference to the mapped value of the element with the specified key.

If no such element exists, an exception of type std::out_of_range is thrown.

Parameters
keythe key of the element to find
Returns
A reference to the mapped value of the requested element.

◆ at() [4/6]

template<typename T , typename Allocator = std::allocator<std::pair<const std::string, T>>>
const T & wpi::StringMap< T, Allocator >::at ( const std::string & key) const
inline

Returns a reference to the mapped value of the element with the specified key.

If no such element exists, an exception of type std::out_of_range is thrown.

Parameters
keythe key of the element to find
Returns
A reference to the mapped value of the requested element.

◆ at() [5/6]

template<typename T , typename Allocator = std::allocator<std::pair<const std::string, T>>>
T & wpi::StringMap< T, Allocator >::at ( std::string_view key)
inline

Returns a reference to the mapped value of the element with the specified key.

If no such element exists, an exception of type std::out_of_range is thrown.

Parameters
keythe key of the element to find
Returns
A reference to the mapped value of the requested element.

◆ at() [6/6]

template<typename T , typename Allocator = std::allocator<std::pair<const std::string, T>>>
const T & wpi::StringMap< T, Allocator >::at ( std::string_view key) const
inline

Returns a reference to the mapped value of the element with the specified key.

If no such element exists, an exception of type std::out_of_range is thrown.

Parameters
keythe key of the element to find
Returns
A reference to the mapped value of the requested element.

◆ contains()

template<typename T , typename Allocator = std::allocator<std::pair<const std::string, T>>>
bool wpi::StringMap< T, Allocator >::contains ( std::string_view key) const
inline

Checks if there is an element with key equal to key in the container.

Parameters
keykey value of the element to search for
Returns
true if there is such an element, otherwise false

◆ count()

template<typename T , typename Allocator = std::allocator<std::pair<const std::string, T>>>
size_type wpi::StringMap< T, Allocator >::count ( std::string_view key) const
inline

Returns the number of elements with key that equals the specified argument.

Parameters
keykey value of the elements to count
Returns
Number of elements with key that equals key (either 0 or 1).

◆ emplace() [1/3]

template<typename T , typename Allocator = std::allocator<std::pair<const std::string, T>>>
template<typename... Args>
std::pair< iterator, bool > wpi::StringMap< T, Allocator >::emplace ( const char * key,
Args &&... args )
inline

Inserts a new element into the container constructed in-place with the given args, if there is no element with the key in the container.

No iterators or references are invalidated.

Parameters
keythe key used both to look up and to insert if not found
argsarguments to forward to the constructor of the element
Returns
A pair consisting of an interator to the inserted element (or to the element that prevented the insertion) and a bool value set to true if and only if the insertion took place.

◆ emplace() [2/3]

template<typename T , typename Allocator = std::allocator<std::pair<const std::string, T>>>
template<typename... Args>
std::pair< iterator, bool > wpi::StringMap< T, Allocator >::emplace ( std::string && key,
Args &&... args )
inline

Inserts a new element into the container constructed in-place with the given args, if there is no element with the key in the container.

No iterators or references are invalidated.

Parameters
keythe key used both to look up and to insert if not found
argsarguments to forward to the constructor of the element
Returns
A pair consisting of an interator to the inserted element (or to the element that prevented the insertion) and a bool value set to true if and only if the insertion took place.

◆ emplace() [3/3]

template<typename T , typename Allocator = std::allocator<std::pair<const std::string, T>>>
template<typename... Args>
std::pair< iterator, bool > wpi::StringMap< T, Allocator >::emplace ( std::string_view key,
Args &&... args )
inline

Inserts a new element into the container constructed in-place with the given args, if there is no element with the key in the container.

No iterators or references are invalidated.

Parameters
keythe key used both to look up and to insert if not found
argsarguments to forward to the constructor of the element
Returns
A pair consisting of an interator to the inserted element (or to the element that prevented the insertion) and a bool value set to true if and only if the insertion took place.

◆ equal_range() [1/2]

template<typename T , typename Allocator = std::allocator<std::pair<const std::string, T>>>
std::pair< iterator, iterator > wpi::StringMap< T, Allocator >::equal_range ( std::string_view key)
inline

Returns a range containing all elements with the given key in the container.

The range is defined by two iterators, one pointing to the first element that is not less than key and another pointing to the first element greater than key. Alternatively, the first iterator may be obtained with lower_bound(), and the second with upper_bound().

Parameters
keykey value to compare the elements to
Returns
std::pair containing a pair of iterators defining the wanted range: the first pointing to the first element that is not less than key and the second pointing to the first element greater than key. If there are no elements not less than key, past-the-end (see end()) iterator is returned as the first element. Similarly if there are no elements greater than key, past-the-end iterator is returned as the second element.

◆ equal_range() [2/2]

template<typename T , typename Allocator = std::allocator<std::pair<const std::string, T>>>
std::pair< const_iterator, const_iterator > wpi::StringMap< T, Allocator >::equal_range ( std::string_view key) const
inline

Returns a range containing all elements with the given key in the container.

The range is defined by two iterators, one pointing to the first element that is not less than key and another pointing to the first element greater than key. Alternatively, the first iterator may be obtained with lower_bound(), and the second with upper_bound().

Parameters
keykey value to compare the elements to
Returns
std::pair containing a pair of iterators defining the wanted range: the first pointing to the first element that is not less than key and the second pointing to the first element greater than key. If there are no elements not less than key, past-the-end (see end()) iterator is returned as the first element. Similarly if there are no elements greater than key, past-the-end iterator is returned as the second element.

◆ erase() [1/5]

template<typename T , typename Allocator = std::allocator<std::pair<const std::string, T>>>
iterator wpi::StringMap< T, Allocator >::erase ( const_iterator first,
const_iterator last )
inline

Removes the elements in the range [first, last), which must be a valid range in this.

Parameters
firstStart of the range of elements to remove
lastEnd of the range of elements to remove
Returns
Iterator following the last removed element.

◆ erase() [2/5]

template<typename T , typename Allocator = std::allocator<std::pair<const std::string, T>>>
iterator wpi::StringMap< T, Allocator >::erase ( const_iterator pos)
inline

Removes the element at pos.

Parameters
positerator to the element to remove
Returns
Iterator following the removed element.

◆ erase() [3/5]

template<typename T , typename Allocator = std::allocator<std::pair<const std::string, T>>>
iterator wpi::StringMap< T, Allocator >::erase ( iterator first,
iterator last )
inline

Removes the elements in the range [first, last), which must be a valid range in this.

Parameters
firstStart of the range of elements to remove
lastEnd of the range of elements to remove
Returns
Iterator following the last removed element.

◆ erase() [4/5]

template<typename T , typename Allocator = std::allocator<std::pair<const std::string, T>>>
iterator wpi::StringMap< T, Allocator >::erase ( iterator pos)
inline

Removes the element at pos.

Parameters
positerator to the element to remove
Returns
Iterator following the removed element.

◆ erase() [5/5]

template<typename T , typename Allocator = std::allocator<std::pair<const std::string, T>>>
size_type wpi::StringMap< T, Allocator >::erase ( std::string_view key)
inline

Removes the element (if one exists) with the key equal to key.

Parameters
keykey value of the elements to remove
Returns
Number of elements removed (0 or 1).

◆ extract() [1/2]

template<typename T , typename Allocator = std::allocator<std::pair<const std::string, T>>>
node_type wpi::StringMap< T, Allocator >::extract ( const_iterator position)
inline

Unlinks the node that contains the element pointed to by position and returns a node handle that owns it.

Parameters
positiona valid iterator into this container
Returns
A node handle that owns the extracted element

◆ extract() [2/2]

template<typename T , typename Allocator = std::allocator<std::pair<const std::string, T>>>
node_type wpi::StringMap< T, Allocator >::extract ( std::string_view key)
inline

If the container has an element with key equal to key, unlinks the node that contains that element from the container and returns a node handle that owns it.

Otherwise, returns an empty node handle.

Parameters
keya key to identify the node to be extracted
Returns
A node handle that owns the extracted element, or empty node handle in case the element is not found.

◆ find() [1/2]

template<typename T , typename Allocator = std::allocator<std::pair<const std::string, T>>>
iterator wpi::StringMap< T, Allocator >::find ( std::string_view key)
inline

Finds an element with key equal to key.

Parameters
keykey value of the element to search for
Returns
An iterator to the requested element. If no such element is found, past-the-end (see end()) iterator is returned.

◆ find() [2/2]

template<typename T , typename Allocator = std::allocator<std::pair<const std::string, T>>>
const_iterator wpi::StringMap< T, Allocator >::find ( std::string_view key) const
inline

Finds an element with key equal to key.

Parameters
keykey value of the element to search for
Returns
An iterator to the requested element. If no such element is found, past-the-end (see end()) iterator is returned.

◆ insert_or_assign() [1/6]

template<typename T , typename Allocator = std::allocator<std::pair<const std::string, T>>>
template<typename M >
std::pair< iterator, bool > wpi::StringMap< T, Allocator >::insert_or_assign ( const char * key,
M && obj )
inline

If a key equal to key already exists in the container, assigns obj to the mapped type corresponding to that key.

If the key does not exist, inserts the value as if by calling insert().

Parameters
keythe key used both to look up and to insert if not found
objthe value to insert or assign
Returns
The bool component is true if the insertion took place and false if the assignment took place. The iterator component is pointing at the element that was inserted or updated.

◆ insert_or_assign() [2/6]

template<typename T , typename Allocator = std::allocator<std::pair<const std::string, T>>>
template<typename M >
iterator wpi::StringMap< T, Allocator >::insert_or_assign ( const_iterator hint,
const char * key,
M && obj )
inline

If a key equal to key already exists in the container, assigns obj to the mapped type corresponding to that key.

If the key does not exist, inserts the value as if by calling insert().

Parameters
hintiterator to the position before which the new element will be inserted
keythe key used both to look up and to insert if not found
objthe value to insert or assign
Returns
Iterator pointing at the element that was inserted or updated.

◆ insert_or_assign() [3/6]

template<typename T , typename Allocator = std::allocator<std::pair<const std::string, T>>>
template<typename M >
iterator wpi::StringMap< T, Allocator >::insert_or_assign ( const_iterator hint,
std::string && key,
M && obj )
inline

If a key equal to key already exists in the container, assigns obj to the mapped type corresponding to that key.

If the key does not exist, inserts the value as if by calling insert().

Parameters
hintiterator to the position before which the new element will be inserted
keythe key used both to look up and to insert if not found
objthe value to insert or assign
Returns
Iterator pointing at the element that was inserted or updated.

◆ insert_or_assign() [4/6]

template<typename T , typename Allocator = std::allocator<std::pair<const std::string, T>>>
template<typename M >
iterator wpi::StringMap< T, Allocator >::insert_or_assign ( const_iterator hint,
std::string_view key,
M && obj )
inline

If a key equal to key already exists in the container, assigns obj to the mapped type corresponding to that key.

If the key does not exist, inserts the value as if by calling insert().

Parameters
hintiterator to the position before which the new element will be inserted
keythe key used both to look up and to insert if not found
objthe value to insert or assign
Returns
Iterator pointing at the element that was inserted or updated.

◆ insert_or_assign() [5/6]

template<typename T , typename Allocator = std::allocator<std::pair<const std::string, T>>>
template<typename M >
std::pair< iterator, bool > wpi::StringMap< T, Allocator >::insert_or_assign ( std::string && key,
M && obj )
inline

If a key equal to key already exists in the container, assigns obj to the mapped type corresponding to that key.

If the key does not exist, inserts the value as if by calling insert().

Parameters
keythe key used both to look up and to insert if not found
objthe value to insert or assign
Returns
The bool component is true if the insertion took place and false if the assignment took place. The iterator component is pointing at the element that was inserted or updated.

◆ insert_or_assign() [6/6]

template<typename T , typename Allocator = std::allocator<std::pair<const std::string, T>>>
template<typename M >
std::pair< iterator, bool > wpi::StringMap< T, Allocator >::insert_or_assign ( std::string_view key,
M && obj )
inline

If a key equal to key already exists in the container, assigns obj to the mapped type corresponding to that key.

If the key does not exist, inserts the value as if by calling insert().

Parameters
keythe key used both to look up and to insert if not found
objthe value to insert or assign
Returns
The bool component is true if the insertion took place and false if the assignment took place. The iterator component is pointing at the element that was inserted or updated.

◆ lower_bound() [1/2]

template<typename T , typename Allocator = std::allocator<std::pair<const std::string, T>>>
iterator wpi::StringMap< T, Allocator >::lower_bound ( std::string_view key)
inline

Returns an iterator pointing to the first element that is not less than (i.e.

greater or equal to) key.

Parameters
keykey value to compare the elements to
Returns
Iterator pointing to the first element that is not less than key. If no such element is found, a past-the-end iterator (see end()) is returned.

◆ lower_bound() [2/2]

template<typename T , typename Allocator = std::allocator<std::pair<const std::string, T>>>
const_iterator wpi::StringMap< T, Allocator >::lower_bound ( std::string_view key) const
inline

Returns an iterator pointing to the first element that is not less than (i.e.

greater or equal to) key.

Parameters
keykey value to compare the elements to
Returns
Iterator pointing to the first element that is not less than key. If no such element is found, a past-the-end iterator (see end()) is returned.

◆ operator=() [1/3]

template<typename T , typename Allocator = std::allocator<std::pair<const std::string, T>>>
StringMap & wpi::StringMap< T, Allocator >::operator= ( const StringMap< T, Allocator > & )
default

Copy assignment operator.

◆ operator=() [2/3]

template<typename T , typename Allocator = std::allocator<std::pair<const std::string, T>>>
StringMap & wpi::StringMap< T, Allocator >::operator= ( std::initializer_list< value_type > ilist)
inline

Replaces the contents with those identified by initializer list ilist.

Parameters
ilistinitializer list to use as data source

◆ operator=() [3/3]

template<typename T , typename Allocator = std::allocator<std::pair<const std::string, T>>>
StringMap & wpi::StringMap< T, Allocator >::operator= ( StringMap< T, Allocator > && ) &&
defaultnoexcept

Move assignment operator.

◆ operator[]() [1/4]

template<typename T , typename Allocator = std::allocator<std::pair<const std::string, T>>>
T & wpi::StringMap< T, Allocator >::operator[] ( const char * key)
inline

Returns a reference to the value that is mapped to a key, performing an insertion if such a key does not exist.

Parameters
keythe key of the element to find
Returns
A reference to the mapped value of the new element if no element with key key existed. Otherwise, a reference to the mapped value of the existing element whose key is equal to key.

◆ operator[]() [2/4]

template<typename T , typename Allocator = std::allocator<std::pair<const std::string, T>>>
T & wpi::StringMap< T, Allocator >::operator[] ( const std::string & key)
inline

Returns a reference to the value that is mapped to a key, performing an insertion if such a key does not exist.

Parameters
keythe key of the element to find
Returns
A reference to the mapped value of the new element if no element with key key existed. Otherwise, a reference to the mapped value of the existing element whose key is equal to key.

◆ operator[]() [3/4]

template<typename T , typename Allocator = std::allocator<std::pair<const std::string, T>>>
T & wpi::StringMap< T, Allocator >::operator[] ( std::string && key)
inline

Returns a reference to the value that is mapped to a key, performing an insertion if such a key does not exist.

Parameters
keythe key of the element to find
Returns
A reference to the mapped value of the new element if no element with key key existed. Otherwise, a reference to the mapped value of the existing element whose key is equal to key.

◆ operator[]() [4/4]

template<typename T , typename Allocator = std::allocator<std::pair<const std::string, T>>>
T & wpi::StringMap< T, Allocator >::operator[] ( std::string_view key)
inline

Returns a reference to the value that is mapped to a key, performing an insertion if such a key does not exist.

Parameters
keythe key of the element to find
Returns
A reference to the mapped value of the new element if no element with key key existed. Otherwise, a reference to the mapped value of the existing element whose key is equal to key.

◆ swap()

template<typename T , typename Allocator = std::allocator<std::pair<const std::string, T>>>
void wpi::StringMap< T, Allocator >::swap ( StringMap< T, Allocator > & other)
inlinenoexcept

Exchanges the contents of the container with those of other.

Does not invoke any move, copy, or swap operations on individual elements.

All iterators and references remain valid. The end() iterator is invalidated.

Parameters
othercontainer to exchange the contents with

◆ try_emplace() [1/6]

template<typename T , typename Allocator = std::allocator<std::pair<const std::string, T>>>
template<typename... Args>
std::pair< iterator, bool > wpi::StringMap< T, Allocator >::try_emplace ( const char * key,
Args &&... args )
inline

If a key equal to key already exists in the container, does nothing.

Otherwise, inserts a new element into the container with key key and value constructed with args.

Parameters
keythe key used both to look up and to insert if not found
argsarguments to forward to the constructor of the element
Returns
A pair consisting of an interator to the inserted element (or to the element that prevented the insertion) and a bool value set to true if and only if the insertion took place.

◆ try_emplace() [2/6]

template<typename T , typename Allocator = std::allocator<std::pair<const std::string, T>>>
template<typename... Args>
iterator wpi::StringMap< T, Allocator >::try_emplace ( const_iterator hint,
const char * key,
Args &&... args )
inline

If a key equal to key already exists in the container, does nothing.

Otherwise, inserts a new element into the container with key key and value constructed with args.

Parameters
hintiterator to the position before which the new element will be inserted
keythe key used both to look up and to insert if not found
argsarguments to forward to the constructor of the element
Returns
An interator to the inserted element, or to the element that prevented the insertion.

◆ try_emplace() [3/6]

template<typename T , typename Allocator = std::allocator<std::pair<const std::string, T>>>
template<typename... Args>
iterator wpi::StringMap< T, Allocator >::try_emplace ( const_iterator hint,
std::string && key,
Args &&... args )
inline

If a key equal to key already exists in the container, does nothing.

Otherwise, inserts a new element into the container with key key and value constructed with args.

Parameters
hintiterator to the position before which the new element will be inserted
keythe key used both to look up and to insert if not found
argsarguments to forward to the constructor of the element
Returns
An interator to the inserted element, or to the element that prevented the insertion.

◆ try_emplace() [4/6]

template<typename T , typename Allocator = std::allocator<std::pair<const std::string, T>>>
template<typename... Args>
iterator wpi::StringMap< T, Allocator >::try_emplace ( const_iterator hint,
std::string_view key,
Args &&... args )
inline

If a key equal to key already exists in the container, does nothing.

Otherwise, inserts a new element into the container with key key and value constructed with args.

Parameters
hintiterator to the position before which the new element will be inserted
keythe key used both to look up and to insert if not found
argsarguments to forward to the constructor of the element
Returns
An interator to the inserted element, or to the element that prevented the insertion.

◆ try_emplace() [5/6]

template<typename T , typename Allocator = std::allocator<std::pair<const std::string, T>>>
template<typename... Args>
std::pair< iterator, bool > wpi::StringMap< T, Allocator >::try_emplace ( std::string && key,
Args &&... args )
inline

If a key equal to key already exists in the container, does nothing.

Otherwise, inserts a new element into the container with key key and value constructed with args.

Parameters
keythe key used both to look up and to insert if not found
argsarguments to forward to the constructor of the element
Returns
A pair consisting of an interator to the inserted element (or to the element that prevented the insertion) and a bool value set to true if and only if the insertion took place.

◆ try_emplace() [6/6]

template<typename T , typename Allocator = std::allocator<std::pair<const std::string, T>>>
template<typename... Args>
std::pair< iterator, bool > wpi::StringMap< T, Allocator >::try_emplace ( std::string_view key,
Args &&... args )
inline

If a key equal to key already exists in the container, does nothing.

Otherwise, inserts a new element into the container with key key and value constructed with args.

Parameters
keythe key used both to look up and to insert if not found
argsarguments to forward to the constructor of the element
Returns
A pair consisting of an interator to the inserted element (or to the element that prevented the insertion) and a bool value set to true if and only if the insertion took place.

◆ upper_bound() [1/2]

template<typename T , typename Allocator = std::allocator<std::pair<const std::string, T>>>
iterator wpi::StringMap< T, Allocator >::upper_bound ( std::string_view key)
inline

Returns an interator pointing to the first element that is greater than key.

Parameters
keykey value to compare the elements to
Returns
Iterator pointing to the first element that is greater than key. If no such element is found, past-the-end (see end()) iterator is returned.

◆ upper_bound() [2/2]

template<typename T , typename Allocator = std::allocator<std::pair<const std::string, T>>>
const_iterator wpi::StringMap< T, Allocator >::upper_bound ( std::string_view key) const
inline

Returns an interator pointing to the first element that is greater than key.

Parameters
keykey value to compare the elements to
Returns
Iterator pointing to the first element that is greater than key. If no such element is found, past-the-end (see end()) iterator is returned.

The documentation for this class was generated from the following file: