In order to disable copying of my class I'm suppose to declare as private but not define operator=(const MyClass&)
and MyClass(const MyClass&)
- do I have to also disable move ctor for this cla开发者_如何学Css?
It is still up to discussion whether move constructors will be implicitly generated (and when).
See this PDF by Stroustrup from 2010-10-17 with the subtitle Should move operations be generated by default?
BTW, in C++0x you can = delete
functions rather than make them priviate and undefined.
class non_copyable {
public:
non_copyable(const non_copyable&) = delete;
non_copyable& operator=(const non_copyable&) = delete;
};
Quoting from the VS 2010 documentation:
Unlike the default copy constructor, the compiler does not provide a default move constructor.
So for VS 2010, it's not necessary to hide that. They don't specifically discuss default move assignment operators, but I assume they won't generate one, either.
精彩评论