#define dealii_filtered_iterator_h
+#include <deal.II/base/std_cxx14/memory.h>
#include <deal.II/base/config.h>
#include <deal.II/base/exceptions.h>
#include <deal.II/base/iterator_range.h>
* Generate a copy of this object, i.e. of the actual type of this
* pointer.
*/
- virtual PredicateBase *clone () const = 0;
+ virtual std::unique_ptr<PredicateBase> clone () const = 0;
};
/**
* 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<PredicateBase> clone () const override;
private:
/**
* Pointer to an object that encapsulated the actual data type of the
* predicate given to the constructor.
*/
- const PredicateBase *predicate;
+ std::unique_ptr<const PredicateBase> predicate;
};
FilteredIterator<BaseIterator>::
~FilteredIterator ()
{
- delete predicate;
- predicate = nullptr;
+ predicate.reset();
}
template <typename BaseIterator>
template <typename Predicate>
-typename FilteredIterator<BaseIterator>::PredicateBase *
+std::unique_ptr<typename FilteredIterator<BaseIterator>::PredicateBase>
FilteredIterator<BaseIterator>::PredicateTemplate<Predicate>::
clone () const
{
- return new PredicateTemplate (predicate);
+ return std_cxx14::make_unique<PredicateTemplate> (predicate);
}