Files
cppdraft_translate/cppdraft/hive/cons.md
2025-10-25 03:02:53 +03:00

11 KiB
Raw Blame History

[hive.cons]

23 Containers library [containers]

23.3 Sequence containers [sequences]

23.3.9 Class template hive [hive]

23.3.9.2 Constructors, copy, and assignment [hive.cons]

🔗

constexpr explicit hive(const Allocator&) noexcept;

1

#

Effects: Constructs an empty hive, using the specified allocator.

2

#

Complexity: Constant.

🔗

constexpr hive(hive_limits block_limits, const Allocator&);

3

#

Effects: Constructs an empty hive, using the specified allocator.

Initializes current-limits with block_limits.

4

#

Complexity: Constant.

🔗

explicit hive(size_type n, const Allocator& = Allocator()); hive(size_type n, hive_limits block_limits, const Allocator& = Allocator());

5

#

Preconditions: T is Cpp17DefaultInsertable into hive.

6

#

Effects: Constructs a hive with n default-inserted elements, using the specified allocator.

If the second overload is called, also initializes current-limits with block_limits.

7

#

Complexity: Linear in n.

🔗

hive(size_type n, const T& value, const Allocator& = Allocator()); hive(size_type n, const T& value, hive_limits block_limits, const Allocator& = Allocator());

8

#

Preconditions: T is Cpp17CopyInsertable into hive.

9

#

Effects: Constructs a hive with n copies of value, using the specified allocator.

If the second overload is called, also initializes current-limits with block_limits.

10

#

Complexity: Linear in n.

🔗

template<class InputIterator> hive(InputIterator first, InputIterator last, const Allocator& = Allocator()); template<class InputIterator> hive(InputIterator first, InputIterator last, hive_limits block_limits, const Allocator& = Allocator());

11

#

Effects: Constructs a hive equal to the range [first, last), using the specified allocator.

If the second overload is called, also initializes current-limits with block_limits.

12

#

Complexity: Linear in distance(first, last).

🔗

template<[container-compatible-range](container.intro.reqmts#concept:container-compatible-range "23.2.2.1Introduction[container.intro.reqmts]")<T> R> hive(from_range_t, R&& rg, const Allocator& = Allocator()); template<[container-compatible-range](container.intro.reqmts#concept:container-compatible-range "23.2.2.1Introduction[container.intro.reqmts]")<T> R> hive(from_range_t, R&& rg, hive_limits block_limits, const Allocator& = Allocator());

13

#

Effects: Constructs a hive object with the elements of the range rg, using the specified allocator.

If the second overload is called, also initializes current-limits with block_limits.

14

#

Complexity: Linear in ranges::distance(rg).

🔗

hive(const hive& x); hive(const hive& x, const type_identity_t<Allocator>& alloc);

15

#

Preconditions: T is Cpp17CopyInsertable into hive.

16

#

Effects: Constructs a hive object with the elements of x.

If the second overload is called, uses alloc.

Initializes current-limits with x.current-limits.

17

#

Complexity: Linear in x.size().

🔗

hive(hive&& x) noexcept; hive(hive&& x, const type_identity_t<Allocator>& alloc);

18

#

Preconditions: For the second overload, when allocator_traits::is_always_equal::value is false,T meets the Cpp17MoveInsertable requirements.

19

#

Effects: When the first overload is called, or the second overload is called andalloc == x.get_allocator() is true,current-limits is set to x.current-limits and each element block is moved from x into *this.

Pointers and references to the elements of x now refer to those same elements but as members of *this.

Iterators referring to the elements of x will continue to refer to their elements, but they now behave as iterators into *this.

If the second overload is called andalloc == x.get_allocator() is false, each element in x is moved into *this.

References, pointers and iterators referring to the elements of x, as well as the past-the-end iterator of x, are invalidated.

20

#

Postconditions: x.empty() is true.

21

#

Complexity: If the second overload is called andalloc == x.get_allocator() is false, linear in x.size().

Otherwise constant.

🔗

hive(initializer_list<T> il, const Allocator& = Allocator()); hive(initializer_list<T> il, hive_limits block_limits, const Allocator& = Allocator());

22

#

Preconditions: T is Cpp17CopyInsertable into hive.

23

#

Effects: Constructs a hive object with the elements of il, using the specified allocator.

If the second overload is called, also initializes current-limits with block_limits.

24

#

Complexity: Linear in il.size().

🔗

hive& operator=(const hive& x);

25

#

Preconditions: T is Cpp17CopyInsertable into hive andCpp17CopyAssignable.

26

#

Effects: All elements in *this are either copy-assigned to, or destroyed.

All elements in x are copied into *this.

[Note 1:

current-limits is unchanged.

— end note]

27

#

Complexity: Linear in size() + x.size().

🔗

hive& operator=(hive&& x) noexcept(allocator_traits<Allocator>::propagate_on_container_move_assignment::value || allocator_traits<Allocator>::is_always_equal::value);

28

#

Preconditions: When(allocator_traits::propagate_on_container_move_assignment::value || allocator_traits::is_always_equal::value) is false,T is Cpp17MoveInsertable into hive andCpp17MoveAssignable.

29

#

Effects: Each element in *this is either move-assigned to, or destroyed.

When(allocator_traits::propagate_on_container_move_assignment::value || get_allocator() == x.get_allocator()) is true,current-limits is set to x.current-limits and each element block is moved from x into *this.

Pointers and references to the elements of x now refer to those same elements but as members of *this.

Iterators referring to the elements of x will continue to refer to their elements, but they now behave as iterators into *this, not into x.

When(allocator_traits::propagate_on_container_move_assignment::value || get_allocator() == x.get_allocator()) is false, each element in x is moved into *this.

References, pointers and iterators referring to the elements of x, as well as the past-the-end iterator of x, are invalidated.

30

#

Postconditions: x.empty() is true.

31

#

Complexity: Linear in size().

If(allocator_traits::propagate_on_container_move_assignment::value || get_allocator() == x.get_allocator()) is false, also linear in x.size().