A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://cplusplus.com/reference/future/future/operator=/ below:

public member function

<future>

std::future::operator= move (1)
future& operator= (future&& rhs) noexcept;
copy [deleted] (2)
future& operator= (const future&) = delete;

Move-assign future

Acquires the shared state of rhs (if any).

If the object was valid (i.e., it had access to a shared state) before the call, it is disassociated from that shared state. If it was the only object associated to that shared state, the former shared state is itself also destroyed.

rhs is left with no shared state (as if default-constructed): it is no longer valid.

future objects cannot be copied (2).



Parameters
rhs
Another future object of the same type (with the same template parameter T).

Return value*this
Example
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
// future::operator=
#include <iostream>       // std::cout
#include <future>         // std::async, std::future

int get_value() { return 10; }

int main ()
{
  std::future<int> fut;           // default-constructed
  fut = std::async (get_value);   // move-assigned

  std::cout << "value: " << fut.get() << '\n';

  return 0;
}

Output:


Data races Both the object and rhs are modified.

Exception safetyNo-throw guarantee: never throws exceptions.

See also
future::future
Construct future (public member function)
future::get
Get value (public member function)

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