[tuple.assign] # 22 General utilities library [[utilities]](./#utilities) ## 22.4 Tuples [[tuple]](tuple#assign) ### 22.4.4 Class template tuple [[tuple.tuple]](tuple.tuple#tuple.assign) #### 22.4.4.3 Assignment [tuple.assign] [1](#1) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2152) For each tuple assignment operator, an exception is thrown only if the assignment of one of the types in Types throws an exception[.](#1.sentence-1) 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[.](#1.sentence-2) [🔗](#lib:operator=,tuple) `constexpr tuple& operator=(const tuple& u); ` [2](#2) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2166) *Effects*: Assigns each element of u to the corresponding element of *this[.](#2.sentence-1) [3](#3) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2171) *Returns*: *this[.](#3.sentence-1) [4](#4) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2175) *Remarks*: This operator is defined as deleted unlessis_copy_assignable_v is true for all i[.](#4.sentence-1) [🔗](#lib:operator=,tuple_) `constexpr const tuple& operator=(const tuple& u) const; ` [5](#5) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2187) *Constraints*: (is_copy_assignable_v && ...) is true[.](#5.sentence-1) [6](#6) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2191) *Effects*: Assigns each element of u to the corresponding element of *this[.](#6.sentence-1) [7](#7) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2195) *Returns*: *this[.](#7.sentence-1) [🔗](#lib:operator=,tuple__) `constexpr tuple& operator=(tuple&& u) noexcept(see below); ` [8](#8) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2206) *Constraints*: is_move_assignable_v is true for all i[.](#8.sentence-1) [9](#9) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2210) *Effects*: For all i, assigns std​::​forward(get(u)) toget(*this)[.](#9.sentence-1) [10](#10) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2215) *Returns*: *this[.](#10.sentence-1) [11](#11) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2219) *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[.](#11.sentence-1) [🔗](#lib:operator=,tuple___) `constexpr const tuple& operator=(tuple&& u) const; ` [12](#12) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2235) *Constraints*: (is_assignable_v && ...) is true[.](#12.sentence-1) [13](#13) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2239) *Effects*: For all i, assigns std​::​forward(get(u)) to get(*this)[.](#13.sentence-1) [14](#14) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2244) *Returns*: *this[.](#14.sentence-1) [🔗](#lib:operator=,tuple____) `template constexpr tuple& operator=(const tuple& u); ` [15](#15) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2255) *Constraints*: - [(15.1)](#15.1) sizeof...(Types) equals sizeof...(UTypes) and - [(15.2)](#15.2) is_assignable_v is true for all i[.](#15.sentence-1) [16](#16) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2262) *Effects*: Assigns each element of u to the corresponding element of *this[.](#16.sentence-1) [17](#17) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2267) *Returns*: *this[.](#17.sentence-1) [🔗](#lib:operator=,tuple_____) `template constexpr const tuple& operator=(const tuple& u) const; ` [18](#18) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2278) *Constraints*: - [(18.1)](#18.1) sizeof...(Types) equals sizeof...(UTypes) and - [(18.2)](#18.2) (is_assignable_v && ...) is true[.](#18.sentence-1) [19](#19) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2287) *Effects*: Assigns each element of u to the corresponding element of *this[.](#19.sentence-1) [20](#20) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2291) *Returns*: *this[.](#20.sentence-1) [🔗](#lib:operator=,tuple______) `template constexpr tuple& operator=(tuple&& u); ` [21](#21) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2302) *Constraints*: - [(21.1)](#21.1) sizeof...(Types) equals sizeof...(UTypes) and - [(21.2)](#21.2) is_assignable_v is true for all i[.](#21.sentence-1) [22](#22) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2309) *Effects*: For all i, assigns std​::​forward(get(u)) toget(*this)[.](#22.sentence-1) [23](#23) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2314) *Returns*: *this[.](#23.sentence-1) [🔗](#lib:operator=,tuple_______) `template constexpr const tuple& operator=(tuple&& u) const; ` [24](#24) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2325) *Constraints*: - [(24.1)](#24.1) sizeof...(Types) equals sizeof...(UTypes) and - [(24.2)](#24.2) (is_assignable_v && ...) is true[.](#24.sentence-1) [25](#25) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2334) *Effects*: For all i, assigns std​::​forward(get(u)) to get(*this)[.](#25.sentence-1) [26](#26) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2339) *Returns*: *this[.](#26.sentence-1) [🔗](#lib:operator=,tuple________) `template constexpr tuple& operator=(const pair& u); ` [27](#27) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2351) *Constraints*: - [(27.1)](#27.1) sizeof...(Types) is 2 and - [(27.2)](#27.2) is_assignable_v is true, and - [(27.3)](#27.3) is_assignable_v is true[.](#27.sentence-1) [28](#28) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2359) *Effects*: Assigns u.first to the first element of *this and u.second to the second element of *this[.](#28.sentence-1) [29](#29) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2364) *Returns*: *this[.](#29.sentence-1) [🔗](#lib:operator=,tuple_________) `template constexpr const tuple& operator=(const pair& u) const; ` [30](#30) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2375) *Constraints*: - [(30.1)](#30.1) sizeof...(Types) is 2, - [(30.2)](#30.2) is_assignable_v is true, and - [(30.3)](#30.3) is_assignable_v is true[.](#30.sentence-1) [31](#31) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2386) *Effects*: Assigns u.first to the first element andu.second to the second element[.](#31.sentence-1) [32](#32) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2391) *Returns*: *this[.](#32.sentence-1) [🔗](#lib:operator=,tuple__________) `template constexpr tuple& operator=(pair&& u); ` [33](#33) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2403) *Constraints*: - [(33.1)](#33.1) sizeof...(Types) is 2 and - [(33.2)](#33.2) is_assignable_v is true, and - [(33.3)](#33.3) is_assignable_v is true[.](#33.sentence-1) [34](#34) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2411) *Effects*: Assigns std​::​forward(u.first) to the first element of *this and std​::​forward(u.second) to the second element of *this[.](#34.sentence-2) [35](#35) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2417) *Returns*: *this[.](#35.sentence-1) [🔗](#lib:operator=,tuple___________) `template constexpr const tuple& operator=(pair&& u) const; ` [36](#36) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2428) *Constraints*: - [(36.1)](#36.1) sizeof...(Types) is 2, - [(36.2)](#36.2) is_assignable_v is true, and - [(36.3)](#36.3) is_assignable_v is true[.](#36.sentence-1) [37](#37) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2439) *Effects*: Assigns std​::​forward(u.first) to the first element and std​::​forward(u.second) to the second element[.](#37.sentence-2) [38](#38) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2444) *Returns*: *this[.](#38.sentence-1) [🔗](#lib:operator=,tuple____________) `template<[tuple-like](tuple.like#concept:tuple-like "22.4.3 Concept tuple-like [tuple.like]") UTuple> constexpr tuple& operator=(UTuple&& u); ` [39](#39) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2456) *Constraints*: - [(39.1)](#39.1) [*different-from*](range.utility.helpers#concept:different-from "25.5.2 Helper concepts [range.utility.helpers]") ([[range.utility.helpers]](range.utility.helpers "25.5.2 Helper concepts")) is true, - [(39.2)](#39.2) remove_cvref_t is not a specialization of ranges​::​subrange, - [(39.3)](#39.3) sizeof...(Types) equals tuple_size_v>, and - [(39.4)](#39.4) is_assignable_v(std​::​forward(u)))> is true for all i[.](#39.sentence-1) [40](#40) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2476) *Effects*: For all i, assigns get(std​::​forward(u)) to get(*this)[.](#40.sentence-1) [41](#41) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2481) *Returns*: *this[.](#41.sentence-1) [🔗](#lib:operator=,tuple_____________) `template<[tuple-like](tuple.like#concept:tuple-like "22.4.3 Concept tuple-like [tuple.like]") UTuple> constexpr const tuple& operator=(UTuple&& u) const; ` [42](#42) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2493) *Constraints*: - [(42.1)](#42.1) [*different-from*](range.utility.helpers#concept:different-from "25.5.2 Helper concepts [range.utility.helpers]") ([[range.utility.helpers]](range.utility.helpers "25.5.2 Helper concepts")) is true, - [(42.2)](#42.2) remove_cvref_t is not a specialization of ranges​::​subrange, - [(42.3)](#42.3) sizeof...(Types) equals tuple_size_v>, and - [(42.4)](#42.4) is_assignable_v(std​::​forward(u)))> is true for all i[.](#42.sentence-1) [43](#43) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2513) *Effects*: For all i, assignsget(std​::​forward(u)) to get(*this)[.](#43.sentence-1) [44](#44) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L2518) *Returns*: *this[.](#44.sentence-1)