-
Notifications
You must be signed in to change notification settings - Fork 58
refactor: use shared_ptr to replace raw pointer #754
Conversation
@@ -49,7 +49,7 @@ class slave_failure_detector_with_multimaster : public dsn::fd::failure_detector | |||
slave_failure_detector_with_multimaster(std::vector<::dsn::rpc_address> &meta_servers, | |||
std::function<void()> &&master_disconnected_callback, | |||
std::function<void()> &&master_connected_callback); | |||
~slave_failure_detector_with_multimaster(void); | |||
virtual ~slave_failure_detector_with_multimaster() {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
virtual ~slave_failure_detector_with_multimaster() {} | |
virtual ~slave_failure_detector_with_multimaster() override {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@neverchanje why need an override
when it's already used virtual
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
override
and virtual
are for different purposes. virtual
disclaims that this function might be inherited by subclasses. But override
indicates that it overrides the parent, i.e dsn::fd::failure_detector
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://en.cppreference.com/w/cpp/language/virtual: Even though destructors are not inherited, if a base class declares its destructor virtual, the derived destructor always overrides it.
https://en.cppreference.com/w/cpp/language/override: In a member function declaration or definition, override specifier ensures that the function is virtual and is overriding a virtual function from a base class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Explicitly annotate overrides of virtual functions or virtual destructors with exactly one of an override or (less frequently) final specifier. Do not use virtual when declaring an override. Rationale: A function or destructor marked override or final that is not an override of a base class virtual function will not compile, and this helps catch common errors. The specifiers serve as documentation; if no specifier is present, the reader has to check all ancestors of the class in question to determine if the function or destructor is virtual or not.
@@ -49,7 +49,7 @@ class slave_failure_detector_with_multimaster : public dsn::fd::failure_detector | |||
slave_failure_detector_with_multimaster(std::vector<::dsn::rpc_address> &meta_servers, | |||
std::function<void()> &&master_disconnected_callback, | |||
std::function<void()> &&master_connected_callback); | |||
~slave_failure_detector_with_multimaster(void); | |||
virtual ~slave_failure_detector_with_multimaster() {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Explicitly annotate overrides of virtual functions or virtual destructors with exactly one of an override or (less frequently) final specifier. Do not use virtual when declaring an override. Rationale: A function or destructor marked override or final that is not an override of a base class virtual function will not compile, and this helps catch common errors. The specifiers serve as documentation; if no specifier is present, the reader has to check all ancestors of the class in question to determine if the function or destructor is virtual or not.
No description provided.