key_value_pair::key_value_pair
Constructors.
Synopsis
template<
class... Args>
explicit
key_value_pair(
string_view key,
Args&&... args); (1)
explicit
key_value_pair(
std::pair< string_view, value > const& p,
storage_ptr sp = {}); (2)
explicit
key_value_pair(
std::pair< string_view, value >&& p,
storage_ptr sp = {}); (3)
key_value_pair(
key_value_pair const& other,
storage_ptr sp); (4)
key_value_pair(
key_value_pair const& other); (5)
key_value_pair(
key_value_pair&& other) noexcept; (6)
key_value_pair(
pilfered< key_value_pair > other) noexcept; (7)
Description
Construct a key/value pair.
-
(1) uses a copy of the characters of
key, and constructs the value as if byvalue(std::forward<Args>(args)...). -
(2) equivalent to
key_value_pair(p.first, p.second, sp). -
(3) equivalent to
key_value_pair(p.first, std::move(p.second), sp). -
(4) equivalent to
key_value_pair(other.key(), other.value(), sp). -
(5) equivalent to
key_value_pair(other.key(), other.value(), other.storage()). -
(6) the pair s constructed by acquiring ownership of the contents of
otherusing move semantics. -
(7) the pair is constructed by acquiring ownership of the contents of
otherusing pilfer semantics. This is more efficient than move construction, when it is known that the moved-from object will be immediately destroyed afterwards.
With (2), (3), (4) the pair uses the memory resource of sp. With (5), (6), (7) it uses the memory resource of other.storage(). With (1) it uses whatever memory resource value(std::forward<Args>(args)...) would use. In any case the pair acquires shared ownership of its memory resource
After (6) other holds an empty key, and a null value with its current storage pointer.
After (7) other is not in a usable state and may only be destroyed.
Complexity
Constant.
Exception Safety
Strong guarantee. Calls to memory_resource::allocate may throw.
Parameters
| Name | Description |
|---|---|
|
The key string to use. |
|
Optional arguments forwarded to the |
|
A |
|
A pointer to the |
|
Another key/value pair. |
Exceptions
| Type | Thrown On |
|---|---|
|
The size of the key would exceed |