How do I pass a unique_ptr argument to a constructor or a function?

前端 未结 7 1640
挽巷
挽巷 2020-11-22 06:16

I\'m new to move semantics in C++11 and I don\'t know very well how to handle unique_ptr parameters in constructors or functions. Consider this class referenc

7条回答
  •  名媛妹妹
    2020-11-22 07:08

    Yes you have to if you take the unique_ptr by value in the constructor. Explicity is a nice thing. Since unique_ptr is uncopyable (private copy ctor), what you wrote should give you a compiler error.

提交回复
热议问题