You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, would it be possible to make the code compile cleanly with -Weffc++? Most of the warnings come from not initializing all class members with initializer lists. However, some of the warnings are about noncopyable. Your implementation doesn't actually prevent anyone from making a copyable object since the deleted copy constructor and assignment operator are only protected, meaning they can still be overridden by derived classes. The only way that I can see to remove every one of the warnings would be to declare these two methods in your classes as "delete" explicitly, I can live with the "has pointer member but does not override..." warnings, as it may not be worth the effort of removing noncopyable entirely. However, it would be really nice if all of the warnings about uninitialized members could be addressed. I can also provide a PR for this, just try it out first with -Weffc++ and let me know what you want to do about noncopyable.
The text was updated successfully, but these errors were encountered:
I've changed a bit noncopyable to following some advices of Scott Mayers, like making public deleted methods. But I prefer to keep it because it's a nice DRY approach to make classes noncopyable.
About uninitialized members, my rule usually is to initialise only ones with non-default init, like integers or object that need special arguments. By the way is not a problem for me to have them on constructor too.
Putting those members public does not prevent people from making copies of those objects though. For example, you can declare a copy constructor in connection:
Hi, would it be possible to make the code compile cleanly with -Weffc++? Most of the warnings come from not initializing all class members with initializer lists. However, some of the warnings are about noncopyable. Your implementation doesn't actually prevent anyone from making a copyable object since the deleted copy constructor and assignment operator are only protected, meaning they can still be overridden by derived classes. The only way that I can see to remove every one of the warnings would be to declare these two methods in your classes as "delete" explicitly, I can live with the "has pointer member but does not override..." warnings, as it may not be worth the effort of removing noncopyable entirely. However, it would be really nice if all of the warnings about uninitialized members could be addressed. I can also provide a PR for this, just try it out first with -Weffc++ and let me know what you want to do about noncopyable.
The text was updated successfully, but these errors were encountered: