UPtrList: Updated iterators for C++11 compliant compilers
Avoids "couldn't deduce template parameter ‘T’" errors. Additionally this patch fixes bur-report https://bugs.openfoam.org/view.php?id=2749
This commit is contained in:
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -54,62 +54,6 @@ template<class T> class PtrList;
|
||||
// Forward declaration of friend functions and operators
|
||||
template<class T> class UPtrList;
|
||||
|
||||
template<class T>
|
||||
inline typename UPtrList<T>::iterator operator+
|
||||
(
|
||||
const typename UPtrList<T>::iterator&,
|
||||
label
|
||||
);
|
||||
|
||||
template<class T>
|
||||
inline typename UPtrList<T>::iterator operator+
|
||||
(
|
||||
label,
|
||||
const typename UPtrList<T>::iterator&
|
||||
);
|
||||
|
||||
template<class T>
|
||||
inline typename UPtrList<T>::iterator operator-
|
||||
(
|
||||
const typename UPtrList<T>::iterator&,
|
||||
label
|
||||
);
|
||||
|
||||
template<class T>
|
||||
inline label operator-
|
||||
(
|
||||
const typename UPtrList<T>::iterator&,
|
||||
const typename UPtrList<T>::iterator&
|
||||
);
|
||||
|
||||
template<class T>
|
||||
inline typename UPtrList<T>::const_iterator operator+
|
||||
(
|
||||
const typename UPtrList<T>::const_iterator&,
|
||||
label
|
||||
);
|
||||
|
||||
template<class T>
|
||||
inline typename UPtrList<T>::const_iterator operator+
|
||||
(
|
||||
label,
|
||||
const typename UPtrList<T>::const_iterator&
|
||||
);
|
||||
|
||||
template<class T>
|
||||
inline typename UPtrList<T>::const_iterator operator-
|
||||
(
|
||||
const typename UPtrList<T>::const_iterator&,
|
||||
label
|
||||
);
|
||||
|
||||
template<class T>
|
||||
inline label operator-
|
||||
(
|
||||
const typename UPtrList<T>::const_iterator&,
|
||||
const typename UPtrList<T>::const_iterator&
|
||||
);
|
||||
|
||||
template<class T>
|
||||
Istream& operator>>(Istream&, UPtrList<T>&);
|
||||
|
||||
@ -239,6 +183,7 @@ public:
|
||||
// Random access iterator for traversing UPtrList
|
||||
|
||||
class iterator;
|
||||
class const_iterator;
|
||||
friend class iterator;
|
||||
|
||||
//- An STL iterator
|
||||
@ -248,6 +193,8 @@ public:
|
||||
|
||||
public:
|
||||
|
||||
friend class const_iterator;
|
||||
|
||||
//- Construct for a given UPtrList entry
|
||||
inline iterator(T**);
|
||||
|
||||
@ -260,27 +207,20 @@ public:
|
||||
inline T& operator()();
|
||||
|
||||
inline iterator operator++();
|
||||
inline iterator operator++(int);
|
||||
inline iterator operator++(const int);
|
||||
|
||||
inline iterator operator--();
|
||||
inline iterator operator--(int);
|
||||
inline iterator operator--(const int);
|
||||
|
||||
inline iterator operator+=(label);
|
||||
inline iterator operator+=(const label);
|
||||
inline iterator operator-=(const label);
|
||||
|
||||
friend iterator operator+ <T>(const iterator&, label);
|
||||
friend iterator operator+ <T>(label, const iterator&);
|
||||
inline iterator operator+(const label) const;
|
||||
inline iterator operator-(const label) const;
|
||||
|
||||
inline iterator operator-=(label);
|
||||
inline label operator-(const iterator&) const;
|
||||
|
||||
friend iterator operator- <T>(const iterator&, label);
|
||||
|
||||
friend label operator- <T>
|
||||
(
|
||||
const iterator&,
|
||||
const iterator&
|
||||
);
|
||||
|
||||
inline T& operator[](label);
|
||||
inline T& operator[](const label);
|
||||
|
||||
inline bool operator<(const iterator&) const;
|
||||
inline bool operator>(const iterator&) const;
|
||||
@ -323,39 +263,20 @@ public:
|
||||
inline Tref operator()();
|
||||
|
||||
inline const_iterator operator++();
|
||||
inline const_iterator operator++(int);
|
||||
inline const_iterator operator++(const int);
|
||||
|
||||
inline const_iterator operator--();
|
||||
inline const_iterator operator--(int);
|
||||
inline const_iterator operator--(const int);
|
||||
|
||||
inline const_iterator operator+=(label);
|
||||
inline const_iterator operator+=(const label);
|
||||
inline const_iterator operator-=(const label);
|
||||
|
||||
friend const_iterator operator+ <T>
|
||||
(
|
||||
const const_iterator&,
|
||||
label
|
||||
);
|
||||
friend const_iterator operator+ <T>
|
||||
(
|
||||
label,
|
||||
const const_iterator&
|
||||
);
|
||||
inline const_iterator operator+(const label) const;
|
||||
inline const_iterator operator-(const label) const;
|
||||
|
||||
inline const_iterator operator-=(label);
|
||||
inline label operator-(const const_iterator&) const;
|
||||
|
||||
friend const_iterator operator- <T>
|
||||
(
|
||||
const const_iterator&,
|
||||
label
|
||||
);
|
||||
|
||||
friend label operator- <T>
|
||||
(
|
||||
const const_iterator&,
|
||||
const const_iterator&
|
||||
);
|
||||
|
||||
inline const T& operator[](label);
|
||||
inline const T& operator[](const label);
|
||||
|
||||
inline bool operator<(const const_iterator&) const;
|
||||
inline bool operator>(const const_iterator&) const;
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -146,30 +146,35 @@ inline Foam::UPtrList<T>::iterator::iterator(T** ptr)
|
||||
ptr_(ptr)
|
||||
{}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline bool Foam::UPtrList<T>::iterator::operator==(const iterator& iter) const
|
||||
{
|
||||
return ptr_ == iter.ptr_;
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline bool Foam::UPtrList<T>::iterator::operator!=(const iterator& iter) const
|
||||
{
|
||||
return ptr_ != iter.ptr_;
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline T& Foam::UPtrList<T>::iterator::operator*()
|
||||
{
|
||||
return **ptr_;
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline T& Foam::UPtrList<T>::iterator::operator()()
|
||||
{
|
||||
return operator*();
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline typename Foam::UPtrList<T>::iterator
|
||||
Foam::UPtrList<T>::iterator::operator++()
|
||||
@ -178,15 +183,17 @@ Foam::UPtrList<T>::iterator::operator++()
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline typename Foam::UPtrList<T>::iterator
|
||||
Foam::UPtrList<T>::iterator::operator++(int)
|
||||
Foam::UPtrList<T>::iterator::operator++(const int)
|
||||
{
|
||||
iterator tmp = *this;
|
||||
++ptr_;
|
||||
return tmp;
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline typename Foam::UPtrList<T>::iterator
|
||||
Foam::UPtrList<T>::iterator::operator--()
|
||||
@ -195,95 +202,98 @@ Foam::UPtrList<T>::iterator::operator--()
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline typename Foam::UPtrList<T>::iterator
|
||||
Foam::UPtrList<T>::iterator::operator--(int)
|
||||
Foam::UPtrList<T>::iterator::operator--(const int)
|
||||
{
|
||||
iterator tmp = *this;
|
||||
--ptr_;
|
||||
return tmp;
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline typename Foam::UPtrList<T>::iterator
|
||||
Foam::UPtrList<T>::iterator::operator+=(label n)
|
||||
Foam::UPtrList<T>::iterator::operator+=(const label n)
|
||||
{
|
||||
ptr_ += n;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline typename Foam::UPtrList<T>::iterator
|
||||
Foam::operator+(const typename UPtrList<T>::iterator& iter, label n)
|
||||
{
|
||||
typename UPtrList<T>::iterator tmp = iter;
|
||||
return tmp += n;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline typename Foam::UPtrList<T>::iterator
|
||||
Foam::operator+(label n, const typename UPtrList<T>::iterator& iter)
|
||||
{
|
||||
typename UPtrList<T>::iterator tmp = iter;
|
||||
return tmp += n;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline typename Foam::UPtrList<T>::iterator
|
||||
Foam::UPtrList<T>::iterator::operator-=(label n)
|
||||
Foam::UPtrList<T>::iterator::operator-=(const label n)
|
||||
{
|
||||
ptr_ -= n;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline typename Foam::UPtrList<T>::iterator
|
||||
Foam::operator-(const typename UPtrList<T>::iterator& iter, label n)
|
||||
Foam::UPtrList<T>::iterator::operator+(const label n) const
|
||||
{
|
||||
typename UPtrList<T>::iterator tmp = iter;
|
||||
typename UPtrList<T>::iterator tmp = *this;
|
||||
return tmp += n;
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline typename Foam::UPtrList<T>::iterator
|
||||
Foam::UPtrList<T>::iterator::operator-(const label n) const
|
||||
{
|
||||
typename UPtrList<T>::iterator tmp = *this;
|
||||
return tmp -= n;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline Foam::label Foam::operator-
|
||||
(
|
||||
const typename UPtrList<T>::iterator& iter1,
|
||||
const typename UPtrList<T>::iterator& iter2
|
||||
)
|
||||
{
|
||||
return (iter1.ptr_ - iter2.ptr_)/sizeof(T*);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline T& Foam::UPtrList<T>::iterator::operator[](label n)
|
||||
inline Foam::label Foam::UPtrList<T>::iterator::operator-
|
||||
(
|
||||
const typename UPtrList<T>::iterator& iter
|
||||
) const
|
||||
{
|
||||
return (ptr_ - iter.ptr_);
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline T& Foam::UPtrList<T>::iterator::operator[](const label n)
|
||||
{
|
||||
return *(*this + n);
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline bool Foam::UPtrList<T>::iterator::operator<(const iterator& iter) const
|
||||
{
|
||||
return ptr_ < iter.ptr_;
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline bool Foam::UPtrList<T>::iterator::operator>(const iterator& iter) const
|
||||
{
|
||||
return ptr_ > iter.ptr_;
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline bool Foam::UPtrList<T>::iterator::operator<=(const iterator& iter) const
|
||||
{
|
||||
return ptr_ <= iter.ptr_;
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline bool Foam::UPtrList<T>::iterator::operator>=(const iterator& iter) const
|
||||
{
|
||||
return ptr_ >= iter.ptr_;
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline typename Foam::UPtrList<T>::iterator
|
||||
Foam::UPtrList<T>::begin()
|
||||
@ -291,6 +301,7 @@ Foam::UPtrList<T>::begin()
|
||||
return ptrs_.begin();
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline typename Foam::UPtrList<T>::iterator
|
||||
Foam::UPtrList<T>::end()
|
||||
@ -360,7 +371,7 @@ Foam::UPtrList<T>::const_iterator::operator++()
|
||||
|
||||
template<class T>
|
||||
inline typename Foam::UPtrList<T>::const_iterator
|
||||
Foam::UPtrList<T>::const_iterator::operator++(int)
|
||||
Foam::UPtrList<T>::const_iterator::operator++(const int)
|
||||
{
|
||||
const_iterator tmp = *this;
|
||||
++ptr_;
|
||||
@ -379,7 +390,7 @@ Foam::UPtrList<T>::const_iterator::operator--()
|
||||
|
||||
template<class T>
|
||||
inline typename Foam::UPtrList<T>::const_iterator
|
||||
Foam::UPtrList<T>::const_iterator::operator--(int)
|
||||
Foam::UPtrList<T>::const_iterator::operator--(const int)
|
||||
{
|
||||
const_iterator tmp = *this;
|
||||
--ptr_;
|
||||
@ -389,7 +400,7 @@ Foam::UPtrList<T>::const_iterator::operator--(int)
|
||||
|
||||
template<class T>
|
||||
inline typename Foam::UPtrList<T>::const_iterator
|
||||
Foam::UPtrList<T>::const_iterator::operator+=(label n)
|
||||
Foam::UPtrList<T>::const_iterator::operator+=(const label n)
|
||||
{
|
||||
ptr_ += n;
|
||||
return *this;
|
||||
@ -398,25 +409,7 @@ Foam::UPtrList<T>::const_iterator::operator+=(label n)
|
||||
|
||||
template<class T>
|
||||
inline typename Foam::UPtrList<T>::const_iterator
|
||||
Foam::operator+(const typename UPtrList<T>::const_iterator& iter, label n)
|
||||
{
|
||||
typename UPtrList<T>::const_iterator tmp = iter;
|
||||
return tmp += n;
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline typename Foam::UPtrList<T>::const_iterator
|
||||
Foam::operator+(label n, const typename UPtrList<T>::const_iterator& iter)
|
||||
{
|
||||
typename UPtrList<T>::const_iterator tmp = iter;
|
||||
return tmp += n;
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline typename Foam::UPtrList<T>::const_iterator
|
||||
Foam::UPtrList<T>::const_iterator::operator-=(label n)
|
||||
Foam::UPtrList<T>::const_iterator::operator-=(const label n)
|
||||
{
|
||||
ptr_ -= n;
|
||||
return *this;
|
||||
@ -425,26 +418,34 @@ Foam::UPtrList<T>::const_iterator::operator-=(label n)
|
||||
|
||||
template<class T>
|
||||
inline typename Foam::UPtrList<T>::const_iterator
|
||||
Foam::operator-(const typename UPtrList<T>::const_iterator& iter, label n)
|
||||
Foam::UPtrList<T>::const_iterator::operator+(const label n) const
|
||||
{
|
||||
typename UPtrList<T>::const_iterator tmp = iter;
|
||||
typename UPtrList<T>::const_iterator tmp = *this;
|
||||
return tmp += n;
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline typename Foam::UPtrList<T>::const_iterator
|
||||
Foam::UPtrList<T>::const_iterator::operator-(const label n) const
|
||||
{
|
||||
typename UPtrList<T>::const_iterator tmp = *this;
|
||||
return tmp -= n;
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline Foam::label Foam::operator-
|
||||
inline Foam::label Foam::UPtrList<T>::const_iterator::operator-
|
||||
(
|
||||
const typename UPtrList<T>::const_iterator& iter1,
|
||||
const typename UPtrList<T>::const_iterator& iter2
|
||||
)
|
||||
const typename UPtrList<T>::const_iterator& iter
|
||||
) const
|
||||
{
|
||||
return (iter1.ptr_ - iter2.ptr_)/sizeof(T*);
|
||||
return (ptr_ - iter.ptr_);
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline const T& Foam::UPtrList<T>::const_iterator::operator[](label n)
|
||||
inline const T& Foam::UPtrList<T>::const_iterator::operator[](const label n)
|
||||
{
|
||||
return *(*this + n);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user