Skip to content

Commit

Permalink
Fix potential slicing with Filter class. (GPSBabel#440)
Browse files Browse the repository at this point in the history
detected by clazy as:
warning: Polymorphic class Filter is copyable. Potential slicing. [-Wclazy-copyable-polymorphic]
  • Loading branch information
tsteven4 authored Dec 17, 2019
1 parent 06f8411 commit 89eef49
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions filter.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,13 @@ class Filter
// its base class type.
// https://wiki.sei.cmu.edu/confluence/display/cplusplus/OOP52-CPP.+Do+not+delete+a+polymorphic+object+without+a+virtual+destructor
virtual ~Filter() = default;
// And that requires us to explicitly default the move and copy operations.
// And that requires us to explicitly default or delete the move and copy operations.
// To prevent slicing we delete them.
// https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#c21-if-you-define-or-delete-any-default-operation-define-or-delete-them-all.
Filter(const Filter&) = default;
Filter& operator=(const Filter&) = default;
Filter(Filter&&) = default;
Filter& operator=(Filter&&) = default;
Filter(const Filter&) = delete;
Filter& operator=(const Filter&) = delete;
Filter(Filter&&) = delete;
Filter& operator=(Filter&&) = delete;

virtual QVector<arglist_t>* get_args() = 0;

Expand Down

0 comments on commit 89eef49

Please sign in to comment.