What are the advantages of boost::noncopyable

前端 未结 11 1220
野性不改
野性不改 2020-11-27 14:10

To prevent copying a class, you can very easily declare a private copy constructor / assignment operators. But you can also inherit boost::noncopyable.

11条回答
  •  误落风尘
    2020-11-27 14:31

    1. The intent of boost::noncopyable is clearer.
    2. Boost::noncopyable prevents the classes methods from accidentally using the private copy constructor.
    3. Less code with boost::noncopyable.

提交回复
热议问题