public member function
<tuple>
std::tuple::operator= copy / move (1)tuple& operator= (const tuple& tpl);tuple& operator= ( tuple&& tpl) noexcept( /* see below */ );implicit conversion (2)
template <class... UTypes> tuple& operator= (const tuple<UTypes...>& tpl);template <class... UTypes> tuple& operator= ( tuple<UTypes...>&& tpl);conversion from pair (3)
template <class U1, class U2> tuple& operator= (const pair<U1,U2>& pr);template <class U1, class U2> tuple& operator= ( pair<U1,U2>&& pr);
Assign content
Assigns tpl (or pr) as the new content for the tuple object.Each of the elements in the tuple object is assigned its corresponding element of tpl (or pr).
The forms taking an lvalue reference as argument perform copy assignments, with the elements of its argument preserving their values after the call. The forms taking an rvalue reference perform move assignments (as if calling forward for each element), which, for elements of types supporting move semantics implies that these elements of tpl (or pr) are left in an unspecified but valid state.
The move assignment (1, second signature) is only noexcept
if all of the types in the tuple are nothrow move-assignable.
*this
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// tuple assignments
#include <iostream> // std::cout
#include <utility> // std::pair
#include <tuple> // std::tuple, std::make_tuple, std::get
int main ()
{
std::pair<int,char> mypair (0,' ');
std::tuple<int,char> a (10,'x');
std::tuple<long,char> b, c;
b = a; // copy assignment
c = std::make_tuple (100L,'Y'); // move assignment
a = c; // conversion assignment
c = std::make_tuple (100,'z'); // conversion / move assignment
a = mypair; // from pair assignment
a = std::make_pair (2,'b'); // form pair /move assignment
std::cout << "c contains: " << std::get<0>(c);
std::cout << " and " << std::get<1>(c) << '\n';
return 0;
}
Output:
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4