Files
2025-10-25 03:02:53 +03:00

13 KiB
Raw Permalink Blame History

[tuple.assign]

22 General utilities library [utilities]

22.4 Tuples [tuple]

22.4.4 Class template tuple [tuple.tuple]

22.4.4.3 Assignment [tuple.assign]

1

#

For each tuple assignment operator, an exception is thrown only if the assignment of one of the types in Types throws an exception.

In the function descriptions that follow, let i be in the range [0, sizeof...(Types)) in order, Ti be the ith type in Types, and Ui be the ith type in a template parameter pack named UTypes, where indexing is zero-based.

🔗

constexpr tuple& operator=(const tuple& u);

2

#

Effects: Assigns each element of u to the corresponding element of *this.

3

#

Returns: *this.

4

#

Remarks: This operator is defined as deleted unlessis_copy_assignable_v is true for all i.

🔗

constexpr const tuple& operator=(const tuple& u) const;

5

#

Constraints: (is_copy_assignable_v && ...) is true.

6

#

Effects: Assigns each element of u to the corresponding element of *this.

7

#

Returns: *this.

🔗

constexpr tuple& operator=(tuple&& u) noexcept(see below);

8

#

Constraints: is_move_assignable_v is true for all i.

9

#

Effects: For all i, assigns std::forward(get(u)) toget(*this).

10

#

Returns: *this.

11

#

Remarks: The exception specification is equivalent to the logical and of the following expressions:is_nothrow_move_assignable_v where Ti is the ith type in Types.

🔗

constexpr const tuple& operator=(tuple&& u) const;

12

#

Constraints: (is_assignable_v<const Types&, Types> && ...) is true.

13

#

Effects: For all i, assigns std::forward(get(u)) to get(*this).

14

#

Returns: *this.

🔗

template<class... UTypes> constexpr tuple& operator=(const tuple<UTypes...>& u);

15

#

Constraints:

sizeof...(Types) equals sizeof...(UTypes) and

is_assignable_v<Ti&, const Ui&> is true for all i.

16

#

Effects: Assigns each element of u to the corresponding element of *this.

17

#

Returns: *this.

🔗

template<class... UTypes> constexpr const tuple& operator=(const tuple<UTypes...>& u) const;

18

#

Constraints:

sizeof...(Types) equals sizeof...(UTypes) and

(is_assignable_v<const Types&, const UTypes&> && ...) is true.

19

#

Effects: Assigns each element of u to the corresponding element of *this.

20

#

Returns: *this.

🔗

template<class... UTypes> constexpr tuple& operator=(tuple<UTypes...>&& u);

21

#

Constraints:

sizeof...(Types) equals sizeof...(UTypes) and

is_assignable_v<Ti&, Ui> is true for all i.

22

#

Effects: For all i, assigns std::forward(get(u)) toget(*this).

23

#

Returns: *this.

🔗

template<class... UTypes> constexpr const tuple& operator=(tuple<UTypes...>&& u) const;

24

#

Constraints:

sizeof...(Types) equals sizeof...(UTypes) and

(is_assignable_v<const Types&, UTypes> && ...) is true.

25

#

Effects: For all i, assigns std::forward(get(u)) to get(*this).

26

#

Returns: *this.

🔗

template<class U1, class U2> constexpr tuple& operator=(const pair<U1, U2>& u);

27

#

Constraints:

sizeof...(Types) is 2 and

is_assignable_v<T0&, const U1&> is true, and

is_assignable_v<T1&, const U2&> is true.

28

#

Effects: Assigns u.first to the first element of *this and u.second to the second element of *this.

29

#

Returns: *this.

🔗

template<class U1, class U2> constexpr const tuple& operator=(const pair<U1, U2>& u) const;

30

#

Constraints:

sizeof...(Types) is 2,

is_assignable_v<const T0&, const U1&> is true, and

is_assignable_v<const T1&, const U2&> is true.

31

#

Effects: Assigns u.first to the first element andu.second to the second element.

32

#

Returns: *this.

🔗

template<class U1, class U2> constexpr tuple& operator=(pair<U1, U2>&& u);

33

#

Constraints:

sizeof...(Types) is 2 and

is_assignable_v<T0&, U1> is true, and

is_assignable_v<T1&, U2> is true.

34

#

Effects: Assigns std::forward(u.first) to the first element of *this and

std::forward(u.second) to the second element of *this.

35

#

Returns: *this.

🔗

template<class U1, class U2> constexpr const tuple& operator=(pair<U1, U2>&& u) const;

36

#

Constraints:

sizeof...(Types) is 2,

is_assignable_v<const T0&, U1> is true, and

is_assignable_v<const T1&, U2> is true.

37

#

Effects: Assigns std::forward(u.first) to the first element and

std::forward(u.second) to the second element.

38

#

Returns: *this.

🔗

template<[tuple-like](tuple.like#concept:tuple-like "22.4.3Concept tuple-like[tuple.like]") UTuple> constexpr tuple& operator=(UTuple&& u);

39

#

Constraints:

different-from<UTuple, tuple> ([range.utility.helpers]) is true,

remove_cvref_t is not a specialization of ranges::subrange,

sizeof...(Types) equals tuple_size_v<remove_cvref_t>, and

is_assignable_v<Ti&, decltype(get(std::forward(u)))> is true for all i.

40

#

Effects: For all i, assigns get(std::forward(u)) to get(*this).

41

#

Returns: *this.

🔗

template<[tuple-like](tuple.like#concept:tuple-like "22.4.3Concept tuple-like[tuple.like]") UTuple> constexpr const tuple& operator=(UTuple&& u) const;

42

#

Constraints:

different-from<UTuple, tuple> ([range.utility.helpers]) is true,

remove_cvref_t is not a specialization of ranges::subrange,

sizeof...(Types) equals tuple_size_v<remove_cvref_t>, and

is_assignable_v<const Ti&, decltype(get(std::forward(u)))> is true for all i.

43

#

Effects: For all i, assignsget(std::forward(u)) to get(*this).

44

#

Returns: *this.