Summary: | [C++11] Should warn when classes only have copy constructor defined | ||
---|---|---|---|
Product: | gcc | Reporter: | Nuno Lopes <nunoplopes> |
Component: | c++ | Assignee: | Not yet assigned to anyone <unassigned> |
Status: | RESOLVED DUPLICATE | ||
Severity: | normal | CC: | webrown.cpp |
Priority: | P3 | Keywords: | diagnostic |
Version: | 11.0 | ||
Target Milestone: | --- | ||
Host: | Target: | ||
Build: | Known to work: | ||
Known to fail: | Last reconfirmed: | ||
Bug Depends on: | |||
Bug Blocks: | 87403 |
Description
Nuno Lopes
2020-08-06 14:31:15 UTC
(In reply to Nuno Lopes from comment #0) > I see a lot of old code that has copy constructors defined, but not move > constructors. This pessimizes code since the definition of the copy > constructor hides the default move constructor. If you need a user-defined copy constructor, a defaulted move constructor probably isn't going to do the right thing anyway. Also, how would users suppress this warning for cases where it's not wanted? Plenty of classes don't need a move constructor because moving is not more efficient than copying, but they don't want a defaulted move constructor. Basically, the code isn't necessarily wrong, and there's no easy way to tell whether the lack of a move constructor is a problem, or should be changed. |