mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-03 07:35:48 +08:00
Iterator classes: removed templated ctors and added static methods to replace them,
for consistency with the container classes and to avoid any potential infinite recursion with MSVC2010. See also commit:6a9065b Also fixed a mistake in CSequence and CCollection, where Pimpl::erase was calling the wrong version of m_impl.erase reported by Roland.
This commit is contained in:
@@ -44,12 +44,6 @@ namespace BlackMisc
|
||||
//! \brief Default constructor.
|
||||
ConstForwardIterator() {}
|
||||
|
||||
/*!
|
||||
* \brief Constructor.
|
||||
* \param i
|
||||
*/
|
||||
template <class I> ConstForwardIterator(I i) : m_pimpl(new Pimpl<I>(std::move(i))) {}
|
||||
|
||||
/*!
|
||||
* \brief Copy constructor.
|
||||
* \param other
|
||||
@@ -62,13 +56,6 @@ namespace BlackMisc
|
||||
*/
|
||||
ConstForwardIterator(ConstForwardIterator &&other) : m_pimpl(other.m_pimpl.take()) {}
|
||||
|
||||
/*!
|
||||
* \brief Assignment.
|
||||
* \param i
|
||||
* \return
|
||||
*/
|
||||
template <class I> ConstForwardIterator &operator =(I i) { m_pimpl.reset(new Pimpl<I>(std::move(i))); return *this; }
|
||||
|
||||
/*!
|
||||
* \brief Copy assignment.
|
||||
* \param other
|
||||
@@ -83,6 +70,14 @@ namespace BlackMisc
|
||||
*/
|
||||
ConstForwardIterator &operator =(ConstForwardIterator &&other) { m_pimpl.reset(other.m_pimpl.take()); return *this; }
|
||||
|
||||
/*!
|
||||
* \brief Create a new iterator with a specific implementation type.
|
||||
* \tparam C Becomes the iterator's implementation type.
|
||||
* \param c Initial value for the iterator. The value is copied.
|
||||
* \return
|
||||
*/
|
||||
template <class I> static ConstForwardIterator fromImpl(I i) { return ConstForwardIterator(new Pimpl<I>(std::move(i))); }
|
||||
|
||||
/*!
|
||||
* \brief Returns a reference to the object pointed to.
|
||||
* \return
|
||||
@@ -183,6 +178,8 @@ namespace BlackMisc
|
||||
typedef QScopedPointer<PimplBase> PimplPtr;
|
||||
PimplPtr m_pimpl;
|
||||
|
||||
explicit ConstForwardIterator(PimplBase *pimpl) : m_pimpl(pimpl) {} // private ctor used by fromImpl()
|
||||
|
||||
// using these methods to access m_pimpl.data() eases the cognitive burden of correctly forwarding const
|
||||
PimplBase *pimpl() { return m_pimpl.data(); }
|
||||
const PimplBase *pimpl() const { return m_pimpl.data(); }
|
||||
@@ -211,12 +208,6 @@ namespace BlackMisc
|
||||
//! \brief Default constructor.
|
||||
ConstBidirectionalIterator() {}
|
||||
|
||||
/*!
|
||||
* \brief Constructor.
|
||||
* \param i
|
||||
*/
|
||||
template <class I> ConstBidirectionalIterator(I i) : m_pimpl(new Pimpl<I>(std::move(i))) {}
|
||||
|
||||
/*!
|
||||
* \brief Copy constructor.
|
||||
* \param other
|
||||
@@ -229,13 +220,6 @@ namespace BlackMisc
|
||||
*/
|
||||
ConstBidirectionalIterator(ConstBidirectionalIterator &&other) : m_pimpl(other.m_pimpl.take()) {}
|
||||
|
||||
/*!
|
||||
* \brief Assignment.
|
||||
* \param i
|
||||
* \return
|
||||
*/
|
||||
template <class I> ConstBidirectionalIterator &operator =(I i) { m_pimpl.reset(new Pimpl<I>(std::move(i))); return *this; }
|
||||
|
||||
/*!
|
||||
* \brief Copy assignment.
|
||||
* \param other
|
||||
@@ -250,6 +234,14 @@ namespace BlackMisc
|
||||
*/
|
||||
ConstBidirectionalIterator &operator =(ConstBidirectionalIterator &&other) { m_pimpl.reset(other.m_pimpl.take()); return *this; }
|
||||
|
||||
/*!
|
||||
* \brief Create a new iterator with a specific implementation type.
|
||||
* \tparam C Becomes the iterator's implementation type.
|
||||
* \param c Initial value for the iterator. The value is copied.
|
||||
* \return
|
||||
*/
|
||||
template <class I> static ConstBidirectionalIterator fromImpl(I i) { return ConstBidirectionalIterator(new Pimpl<I>(std::move(i))); }
|
||||
|
||||
/*!
|
||||
* \brief Returns a reference to the object pointed to.
|
||||
* \return
|
||||
@@ -404,6 +396,8 @@ namespace BlackMisc
|
||||
typedef QScopedPointer<PimplBase> PimplPtr;
|
||||
PimplPtr m_pimpl;
|
||||
|
||||
explicit ConstBidirectionalIterator(PimplBase *pimpl) : m_pimpl(pimpl) {} // private ctor used by fromImpl()
|
||||
|
||||
// using these methods to access m_pimpl.data() eases the cognitive burden of correctly forwarding const
|
||||
PimplBase *pimpl() { return m_pimpl.data(); }
|
||||
const PimplBase *pimpl() const { return m_pimpl.data(); }
|
||||
@@ -432,12 +426,6 @@ namespace BlackMisc
|
||||
//! \brief Default constructor.
|
||||
BidirectionalIterator() {}
|
||||
|
||||
/*!
|
||||
* \brief Constructor.
|
||||
* \param i
|
||||
*/
|
||||
template <class I> BidirectionalIterator(I i) : m_pimpl(new Pimpl<I>(std::move(i))) {}
|
||||
|
||||
/*!
|
||||
* \brief Copy constructor.
|
||||
* \param other
|
||||
@@ -450,13 +438,6 @@ namespace BlackMisc
|
||||
*/
|
||||
BidirectionalIterator(BidirectionalIterator &&other) : m_pimpl(other.m_pimpl.take()) {}
|
||||
|
||||
/*!
|
||||
* \brief Assignment.
|
||||
* \param i
|
||||
* \return
|
||||
*/
|
||||
template <class I> BidirectionalIterator &operator =(I i) { m_pimpl.reset(new Pimpl<I>(std::move(i))); return *this; }
|
||||
|
||||
/*!
|
||||
* \brief Copy assignment.
|
||||
* \param other
|
||||
@@ -471,6 +452,14 @@ namespace BlackMisc
|
||||
*/
|
||||
BidirectionalIterator &operator =(BidirectionalIterator &&other) { m_pimpl.reset(other.m_pimpl.take()); return *this; }
|
||||
|
||||
/*!
|
||||
* \brief Create a new iterator with a specific implementation type.
|
||||
* \tparam C Becomes the iterator's implementation type.
|
||||
* \param c Initial value for the iterator. The value is copied.
|
||||
* \return
|
||||
*/
|
||||
template <class I> static BidirectionalIterator fromImpl(I i) { return BidirectionalIterator(new Pimpl<I>(std::move(i))); }
|
||||
|
||||
/*!
|
||||
* \brief Returns a reference to the object pointed to.
|
||||
* \return
|
||||
@@ -641,6 +630,8 @@ namespace BlackMisc
|
||||
typedef QScopedPointer<PimplBase> PimplPtr;
|
||||
PimplPtr m_pimpl;
|
||||
|
||||
explicit BidirectionalIterator(PimplBase *pimpl) : m_pimpl(pimpl) {} // private ctor used by fromImpl()
|
||||
|
||||
// using these methods to access m_pimpl.data() eases the cognitive burden of correctly forwarding const
|
||||
PimplBase *pimpl() { return m_pimpl.data(); }
|
||||
const PimplBase *pimpl() const { return m_pimpl.data(); }
|
||||
|
||||
Reference in New Issue
Block a user