2 Matching Annotations
  1. Apr 2022
    1. Because std::unique_ptr is designed with move semantics in mind, copy initialization and copy assignment are disabled. If you want to transfer the contents managed by std::unique_ptr, you must use move semantics.

      std::unique_ptr 可以使用 copy 初始化吗?

    1. the goal of the move constructor and move assignment is to move ownership of the resources from one object to another (which is typically much less expensive than making a copy).

      move constructor 和 move assignment 的目的是什么?