7 ms·
I put private : myclass(const &myclass )=delete; Just to be safe :-)
by jpm48 5y ago
I put
private :
myclass(const &myclass )=delete;
Just to be safe :-)
- bialpio 5y agoIIRC this will make the compiler error less helpful than it could be? I think you'd get an "attempt to use private member" instead of "attempt to use deleted member". End result is probably the same, but it feels like you're not saying what you mean with the code. Edit: NVM, looks like all major compilers will say that the copy ctor is deleted. https://godbolt.org/z/jTd3714Tb https://godbolt.org/z/jTd3714Tb
- Psychlist 5y agoclang-tidy will ask that you put in the full set. Foo() = delete; Foo(const Foo& orig) = delete; Foo(Foo&& orig) = delete; Foo operator=(const Foo &other) = delete; Foo operator=(Foo &&other) = delete; (add const to taste)
- ziml77 5y agoFunny thing there is that one could read that as saying that the copy constructor's deletion is private and therefore still accessible in the public interface. I wouldn't put it past C++ to do something as crazy as that.