Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

Migrate away from boost::noncopyable to deleting copy c'tor and copy assignment #19793

Open Quuxplusone opened 10 years ago

Quuxplusone commented 10 years ago
Bugzilla Link PR19794
Status NEW
Importance P enhancement
Reported by Richard (legalize@xmission.com)
Reported on 2014-05-19 14:00:19 -0700
Last modified on 2016-07-14 20:26:51 -0700
Version unspecified
Hardware PC Windows NT
CC alexfh@google.com, djasper@google.com, edwin.vane@intel.com, eugene.zelenko@gmail.com, klimek@google.com, prazek@google.com
Fixed by commit(s)
Attachments
Blocks
Blocked by
See also

boost/noncopyable.hpp gives the user a base class from which they can derive in order to prevent a class from being copyable. See http://www.boost.org/doc/libs/1_55_0/boost/noncopyable.hpp

clang-modernize could refactor this to eliminate the base class derivation and explicitly delete the copy c'tor and copy assignment operators. (noncopyable.hpp does this right now if boost can detect you have a compliant compiler).

This would be a change that moves you from a boost mechanism to a C++11 standard mechanism. Some people may not like this, so perhaps it should be an option instead of a just "do it always" sort of change.

Quuxplusone commented 8 years ago
Possible name for this check:
modernize-use-deleted-methods
Quuxplusone commented 8 years ago

If the check will make it, then I guess it should be in boost module.

The better question is should it make it. I was modernizing much code that was using boost::noncopyable, and I decided to not touch this, because IMHO boost::noncopyable is much shorter and cleaner way of saying that the class should not be copyable. Of course there are some drawback of both - using delete you could forget to delete some functions that you should and using boost::nonocopyable you can have multiple inheritence, which are consider bad and many other subtle problems.

So I think there are some needs for this check, but I think there are better checks waiting to be written that solves bigger or wider problems.