I have a NonCopyable
class and an Application
class derived from NonCopyable
:
class NonCopyable
{
public:
NonCopyable() = default;
virtual ~NonCopyable() = default;
NonCopyable(NonCopyable const&) = delete;
NonCopyable& operator =(NonCopyable const&) = delete;
NonCopyable(NonCopyable&&) = delete;
NonCopyable& operator=(NonCopyable&&) = delete;
};
class Application : public NonCopyable
{
public:
~Application() { /* ...delete stuff... */ }
};
As you see, I don't need to redeclare deleted move constructors or assignment operators as I've declared them in the base class. But why does Resharper suggest me to declare other special member functions? It said:
Class
Application
defines a non-default destructor but does not define a copy constructor, a copy assignment operator, a move constructor or a move assignment operator [hicpp-special-member-functions].There're also [cppcoreguidelines-special-member-functions] reminders with the same message.
The current workaround is to explicitly write all of them to make the warning go away:
class Application : public NonCopyable
{
public:
~Application() { /* ...delete stuff... */ }
Application(Application const&) = delete;
Application& operator =(Application const&) = delete;
Application(Application&&) = delete;
Application& operator=(Application&&) = delete;
};
Application
instance (singleton) so there isn't a need of copy constructor. – MiPResharper
has its own logic based on which it create a list of warning. If warning are not fatal you can just ignore it. It not necessary that you have done some mistake. – Abhijit Pritam DuttaAlt+Enter
on the inspection, then going into inspection submenu and selectingOpen documentation
. In the same submenu you can change inspection severity or switch it off altogether. – Igor Akhmetov