Search code examples
c++c++11shared-ptr

Is the state of any standard class after being moved specified?


If I move shared_ptr 'a' into shared_ptr 'b' is 'a' guaranteed to be null?

Is the state of any standard class after being moved specified?


Solution

  • In general 17.6.5.15/1 applies:

    Objects of types defined in the C++ standard library may be moved from (12.8). Move operations may be explicitly specified or implicitly generated. Unless otherwise specified, such moved-from objects shall be placed in a valid but unspecified state.

    Thus you can call any functions which requires no precondition.

    If specified, what @Xeo said applies.