18 #ifndef LIBMESH_VARIANT_FILTER_ITERATOR_H 19 #define LIBMESH_VARIANT_FILTER_ITERATOR_H 28 #if defined(__GNUC__) && (__GNUC__ < 3) && !defined(__INTEL_COMPILER) 49 template<
class Predicate,
class Type,
class ReferenceType = Type &,
class Po
interType = Type *>
51 #if defined(__GNUC__) && (__GNUC__ < 3) && !defined(__INTEL_COMPILER) 52 public std::forward_iterator<std::forward_iterator_tag, Type>
54 public std::iterator<std::forward_iterator_tag, Type>
61 typedef variant_filter_iterator<Predicate, Type, ReferenceType, PointerType> Iterator;
74 virtual ~IterBase() {}
75 virtual IterBase * clone()
const = 0;
80 virtual ReferenceType
operator*()
const = 0;
87 virtual bool equal(
const IterBase * other)
const = 0;
90 typedef typename variant_filter_iterator<Predicate, Type const, Type const & , Type const *>::IterBase const_IterBase;
97 virtual const_IterBase * const_clone()
const = 0;
111 virtual ~PredBase() {}
112 virtual PredBase * clone()
const = 0;
113 virtual bool operator()(
const IterBase * in)
const = 0;
116 typedef typename variant_filter_iterator<Predicate, Type const, Type const &, Type const *>::PredBase const_PredBase;
123 virtual const_PredBase * const_clone()
const = 0;
135 template<
typename IterType>
136 struct Iter : IterBase
142 Iter (
const IterType & v) :
152 Iter (
const Iter & other) :
166 virtual IterBase * clone()
const override 169 variant_filter_iterator::Iter<IterType> * copy =
170 new variant_filter_iterator::Iter<IterType>(
iter_data);
172 Iter<IterType> * copy =
183 virtual typename IterBase::const_IterBase * const_clone()
const override 189 typedef typename variant_filter_iterator<Predicate, Type const, Type const &, Type const *>::template Iter<IterType> const_Iter;
191 typename IterBase::const_IterBase * copy =
200 virtual ReferenceType
operator*()
const override 220 virtual bool equal(
const IterBase * other)
const override 222 #if defined(__SUNPRO_CC) || (defined(__GNUC__) && (__GNUC__ < 3) && !defined(__INTEL_COMPILER)) 223 const variant_filter_iterator::Iter<IterType> * p =
224 libMesh::cast_ptr<const variant_filter_iterator::Iter<IterType> *>(other);
226 const Iter<IterType> * p =
227 libMesh::cast_ptr<const Iter<IterType> *>(other);
247 template <
typename IterType,
typename PredType>
264 virtual PredBase *
clone()
const override 267 variant_filter_iterator::Pred<IterType,PredType> * copy =
268 new variant_filter_iterator::Pred<IterType,PredType>(pred_data);
281 virtual typename PredBase::const_PredBase *
const_clone()
const override 287 typedef typename variant_filter_iterator<Predicate, Type const, Type const &, Type const *>::template
Pred<IterType, PredType> const_Pred;
290 typename PredBase::const_PredBase * copy =
291 new const_Pred(pred_data);
302 virtual bool operator() (
const IterBase * in)
const override 307 #if defined(__SUNPRO_CC) || (defined(__GNUC__) && (__GNUC__ < 3) && !defined(__INTEL_COMPILER)) 308 const variant_filter_iterator::Iter<IterType> * p =
309 libMesh::cast_ptr<const variant_filter_iterator::Iter<IterType> * >(in);
311 const Iter<IterType> * p =
312 libMesh::cast_ptr<const Iter<IterType> *>(in);
316 return pred_data(p->iter_data);
363 template<
typename PredType,
typename IterType>
366 const PredType & p ):
367 data ( new Iter<IterType>(d) ),
368 end ( new Iter<IterType>(e) ),
369 pred ( new
Pred<IterType,PredType>(p) )
387 data (rhs.
data != nullptr ? rhs.
data->clone() : nullptr),
388 end (rhs.
end != nullptr ? rhs.
end->clone() : nullptr),
389 pred (rhs.
pred != nullptr ? rhs.
pred->clone() : nullptr) {}
404 template <
class OtherType,
class OtherReferenceType,
class OtherPo
interType>
406 :
data (rhs.
data != nullptr ? rhs.
data->const_clone() : nullptr),
407 end (rhs.
end != nullptr ? rhs.
end->const_clone() : nullptr),
408 pred (rhs.
pred != nullptr ? rhs.
pred->const_clone() : nullptr)
424 delete end;
end =
nullptr;
460 Iterator oldValue(*
this);
472 return data->equal(other.data);
478 void swap(Iterator & lhs, Iterator & rhs)
521 template<
class Predicate,
class Type,
class ReferenceType,
class Po
interType>
523 bool operator==(
const variant_filter_iterator<Predicate, Type, ReferenceType, PointerType> & x,
524 const variant_filter_iterator<Predicate, Type, ReferenceType, PointerType> & y)
532 template<
class Predicate,
class Type,
class ReferenceType,
class Po
interType>
534 bool operator!=(
const variant_filter_iterator<Predicate, Type, ReferenceType, PointerType> & x,
535 const variant_filter_iterator<Predicate, Type, ReferenceType, PointerType> & y)
542 #endif // LIBMESH_VARIANT_FILTER_ITERATOR_H variant_filter_iterator(const IterType &d, const IterType &e, const PredType &p)
bool equal(const variant_filter_iterator &other) const
bool operator!=(const variant_filter_iterator< Predicate, Type, ReferenceType, PointerType > &x, const variant_filter_iterator< Predicate, Type, ReferenceType, PointerType > &y)
virtual PredBase::const_PredBase * const_clone() const override
virtual PredBase * clone() const override
PointerType operator->() const
virtual ~variant_filter_iterator()
void swap(Iterator &lhs, Iterator &rhs)
bool operator==(const variant_filter_iterator< Predicate, Type, ReferenceType, PointerType > &x, const variant_filter_iterator< Predicate, Type, ReferenceType, PointerType > &y)
Iterator & operator=(const Iterator &rhs)
ReferenceType operator*() const