object::object
Constructors.
Synopsis
object() noexcept; (1)
explicit
object(
storage_ptr sp) noexcept; (2)
object(
std::size_t min_capacity,
storage_ptr sp = {}); (3)
template<
class InputIt>
object(
InputIt first,
InputIt last,
std::size_t min_capacity = 0,
storage_ptr sp = {}); (4)
object(
std::initializer_list< std::pair< string_view, value_ref > > init,
storage_ptr sp = {}); (5)
object(
std::initializer_list< std::pair< string_view, value_ref > > init,
std::size_t min_capacity,
storage_ptr sp = {}); (6)
object(
object const& other); (7)
object(
object const& other,
storage_ptr sp); (8)
object(
object&& other) noexcept; (9)
object(
object&& other,
storage_ptr sp); (10)
object(
pilfered< object > other) noexcept; (11)
Description
Constructs an object.
-
(1)–(3) the object is empty.
-
(4) the object is filled with values in the range
[first, last)
. -
(5), (6) the object is filled with copies of the values in
init
. -
(7), (8) the object is filled with copies of the elements of
other
. -
(9) the object acquires ownership of the contents of
other
. -
(10) equivalent to (9) if
*sp == *other.storage()
; otherwise equivalent to (8). -
(11) the object acquires ownership of the contents of
other
using pilfer semantics. This is more efficient than move construction, when it is known that the moved-from object will be immediately destroyed afterwards.
Upon construction, capacity()
will be large enough to store the object’s elements. In addition, with (3), (4), and (6) the capacity will not be smaller than min_capacity
.
With (2)–(6), (8), (10) the constructed object uses memory resource of sp
. With (7), (9), (11) it uses other
's memory resource. In either case the object will share the ownership of the memory resource. With (1) it uses the default memory resource.
After (9) other
behaves as if newly constructed with its current storage pointer.
After (11) other
is not in a usable state and may only be destroyed.
If init
or [first, last)
have elements with duplicate keys, only the first of those equivalent elements will be inserted.
Constraints
std::is_constructible_v<
key_value_pair,
std::iterator_traits<InputIt>::reference>
Complexity
-
(1)–(3), (9), (11) constant.
-
(4) linear in
std::distance(first, last)
. -
(5), (6) linear in
init.size()
. -
(7), (8) linear in
other.size()
. -
(10) constant if
*sp == *other.storage()
; otherwise linear inother.size()
.
Exception Safety
-
(1), (2), (9), (11) no-throw guarantee.
-
(3), (5), (6)–(8), (10) strong guarantee.
-
(4) strong guarantee if
InputIt
satisfies LegacyForwardIterator, basic guarantee otherwise.
Calls to memory_resource::allocate
may throw.
Template Parameters
Type | Description |
---|---|
|
a type satisfying the requirements of LegacyInputIterator. |
Parameters
Name | Description |
---|---|
|
A pointer to the |
|
The minimum number of elements for which capacity is guaranteed without a subsequent reallocation. |
|
An input iterator pointing to the first element to insert, or pointing to the end of the range. |
|
An input iterator pointing to the end of the range. |
|
The initializer list to insert. |
|
Another object. |