From b89eac5eafabced6fbb69fbc148b8a9647b98f27 Mon Sep 17 00:00:00 2001 From: Daniel Arndt Date: Wed, 28 Mar 2018 18:37:13 +0200 Subject: [PATCH] Let Predicate*::clone return a std::unique_ptr --- include/deal.II/grid/filtered_iterator.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/include/deal.II/grid/filtered_iterator.h b/include/deal.II/grid/filtered_iterator.h index 9268c71dc5..c3f45e512a 100644 --- a/include/deal.II/grid/filtered_iterator.h +++ b/include/deal.II/grid/filtered_iterator.h @@ -17,6 +17,7 @@ #define dealii_filtered_iterator_h +#include #include #include #include @@ -703,7 +704,7 @@ private: * Generate a copy of this object, i.e. of the actual type of this * pointer. */ - virtual PredicateBase *clone () const = 0; + virtual std::unique_ptr clone () const = 0; }; @@ -727,13 +728,13 @@ private: /** * Evaluate the iterator with the stored copy of the predicate. */ - virtual bool operator () (const BaseIterator &bi) const; + virtual bool operator () (const BaseIterator &bi) const override; /** * Generate a copy of this object, i.e. of the actual type of this * pointer. */ - virtual PredicateBase *clone () const; + virtual std::unique_ptr clone () const override; private: /** @@ -746,7 +747,7 @@ private: * Pointer to an object that encapsulated the actual data type of the * predicate given to the constructor. */ - const PredicateBase *predicate; + std::unique_ptr predicate; }; @@ -944,8 +945,7 @@ inline FilteredIterator:: ~FilteredIterator () { - delete predicate; - predicate = nullptr; + predicate.reset(); } @@ -1178,11 +1178,11 @@ operator () (const BaseIterator &bi) const template template -typename FilteredIterator::PredicateBase * +std::unique_ptr::PredicateBase> FilteredIterator::PredicateTemplate:: clone () const { - return new PredicateTemplate (predicate); + return std_cxx14::make_unique (predicate); } -- 2.39.5