C ++: for which objects, being "moved", is implied more than "staying in force"?

Considering that athey bare of type T, we either move the construction ( T b(move(a));) or move the destination ( b = move(a)). In what cases do we know what will matter a?

The only thing I know for sure is unique_ptrthat in which it awill become an empty pointer. Is it also guaranteed for shared_ptr? Are there other classes for which the standard guarantees a known value?

+4
source share
1 answer

Standard library types

N4296, §17.6.3.1, rv - T, 20, MoveConstructible 22 MoveAssignable.

:

T(rv);
T u =rv;
u = rv;

rvs [: rv . , , , rv . - ]

, . . .

shared_ptr:

shared_ptr(shared_ptr&& r) noexcept;
template<class Y> shared_ptr(shared_ptr<Y>&& r) noexcept;

. , Y * T *.

: Move-constructs shared_ptr r. : * r. r . r.get() == nullptr.

. ...

, , !

+1

Source: https://habr.com/ru/post/1663732/


All Articles