From: Daniel Arndt Date: Wed, 28 Mar 2018 16:37:13 +0000 (+0200) Subject: Let Predicate*::clone return a std::unique_ptr X-Git-Tag: v9.0.0-rc1~267^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F6112%2Fhead;p=dealii.git Let Predicate*::clone return a std::unique_ptr --- 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); }