public member function
<functional>
std::reference_wrapper::operator=reference_wrapper& operator= (const reference_wrapper& rhs) noexcept;
Copy assignment
Copies the reference held by rhs, replacing the reference currently held in*this
.
After the call, both rhs and *this
refer to the same object or function.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// reference_wrapper::operator=
#include <iostream> // std::cout
#include <functional> // std::reference_wrapper
int main () {
int a,b;
// reference_wrapper assignment:
a=10; b=20;
std::reference_wrapper<int> wrap1 (a);
std::reference_wrapper<int> wrap2 (b);
wrap1 = wrap2;
++wrap1; ++wrap2;
std::cout << "a: " << a << '\n';
std::cout << "b: " << b << '\n';
std::cout << '\n';
// note the difference with:
a=10; b=20;
int& ref1 (a);
int& ref2 (b);
ref1 = ref2;
++ref1; ++ref2;
std::cout << "a: " << a << '\n';
std::cout << "b: " << b << '\n';
return 0;
}
rhs.get()
), which can be used to access or modify it.
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