Add virtual destructors

Summary:
Virtual destructors were missing in classes/structs which can
be inherited.
A missing virtual destructor gives undefined behaviour when
deleting derived class using base type.

Reviewers: teon.banek

Reviewed By: teon.banek

Subscribers: pullbot

Differential Revision: https://phabricator.memgraph.io/D1117
This commit is contained in:
Dominik Gleich 2018-01-18 17:23:58 +01:00
parent f0156955f0
commit 07d262cd1e
2 changed files with 5 additions and 0 deletions

View File

@ -16,6 +16,7 @@ class Common : public TotalOrdering<TSpecificType> {
Common() {}
explicit Common(const StorageT storage) : storage_(storage) {}
virtual ~Common() {}
friend bool operator==(const TSpecificType &a, const TSpecificType &b) {
return a.storage_ == b.storage_;

View File

@ -11,6 +11,8 @@
*/
template <typename TLhs, typename TRhs = TLhs, typename TReturn = bool>
struct TotalOrdering {
virtual ~TotalOrdering() {}
friend constexpr TReturn operator!=(const TLhs& a, const TRhs& b) {
return !(a == b);
}
@ -30,6 +32,8 @@ struct TotalOrdering {
template <class Derived, class T>
struct TotalOrderingWith {
virtual ~TotalOrderingWith() {}
friend constexpr bool operator!=(const Derived& a, const T& b) {
return !(a == b);
}