Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

value::operator= (20 of 24 overloads)
PrevUpHomeNext

Assignment.

Synopsis
value&
operator=(
    string&& s);
Description

The contents of the value are replaced with the contents of s using move semantics:

  • If *other.storage() == *this->storage(), ownership of the underlying memory is transferred in constant time, with no possibility of exceptions. After assignment, the moved-from string becomes empty with its current storage pointer.
  • If *other.storage() != *this->storage(), an element-wise copy is performed, which may throw. In this case, the moved-from string is not changed.
Complexity

Constant, or linear in the size of *this plus s.size().

Exception Safety

Strong guarantee. Calls to memory_resource::allocate may throw.

Parameters

Name

Description

s

The string to move-assign from.


PrevUpHomeNext