c++ - Add unique_ptr as instance field of a class instead of explicitly removing copy / assignment ctors -


there macros preventing classes being copied, eg: macros disallow class copy , assignment. google -vs- qt

would identical results having unique_ptr in class? if so, there reason not this? eg

class foo {   private:     std::unique_ptr<int> disable_copy; }; 

the disallow macros meant c++98/03. c++11 has = delete operator eliminating copy/assignment. adding unique_ptr bloat class little bit, worse think it's roundabout , unclear way implement deleted copy/assignment.

class foo { public:   foo(const foo&) = delete;   foo& operator=(const foo&) = delete; }; 

will achieve these results clearly.


Comments

Popular posts from this blog

Java 3D LWJGL collision -

spring - SubProtocolWebSocketHandler - No handlers -

methods - python can't use function in submodule -