#pragma once #include "Iterator.Base.tlh" #include "Iterator.Random.tlh" #include "VectorOfPtr.tlh" //----------------------------------------------------------------------------- // VectorOfPtr // 偏特化 - 常量 //----------------------------------------------------------------------------- namespace Iterator { template class _VP_ConstIterator : public __RandomIterator ::const_iterator> { typedef __RandomIterator ::const_iterator> inherited; public: // using inherited::inherited; // VC2013 编译错误 // using __Iterator >::__Iterator >; using deref_type = const T; using value_type = const T *; using data_type = const T *; _VP_ConstIterator () : inherited () { } _VP_ConstIterator (const VectorOfPtr & ar) { InitFrom (ar); } _VP_ConstIterator (const _VP_ConstIterator & from) : inherited (from) { } _VP_ConstIterator (_VP_ConstIterator && from) : inherited (from) { } public: _VP_ConstIterator & operator = (const _VP_ConstIterator & from) { inherited::operator = (from); return (*this); } _VP_ConstIterator & operator = (_VP_ConstIterator && from) { inherited::operator = (from); return (*this); } public: inline data_type Current () { return (*(this->m_stdIter)).get (); } inline data_type operator () () { return Current (); } inline data_type operator * () { return Current (); } protected: void InitFrom (const VectorOfPtr & ar) { this->m_stdIter = this->m_stdBegin = ar.cbegin (); this->m_stdEnd = ar.cend (); this->m_Count = (int)ar.size (); this->m_Index = 0; } }; } //----------------------------------------------------------------------------- // VectorOfPtr // 偏特化 - 变量 //----------------------------------------------------------------------------- namespace Iterator { template class _VP_Iterator : public __RandomIterator ::iterator> { typedef __RandomIterator ::iterator> inherited; public: // using inherited::inherited; // VC2013 编译错误 // using __Iterator >::__Iterator >; using deref_type = T; using value_type = T *; using data_type = T *; _VP_Iterator () : inherited () { } _VP_Iterator (VectorOfPtr & ar) { InitFrom (ar); } _VP_Iterator (const _VP_Iterator & from) : inherited (from) { } _VP_Iterator (_VP_Iterator && from) : inherited (from) { } public: inline _VP_Iterator & operator = (const _VP_Iterator & from) { inherited::operator = (from); return (*this); } inline _VP_Iterator & operator = (_VP_Iterator && from) { inherited::operator = (from); return (*this); } public: inline data_type Current () { return (*(this->m_stdIter)).get (); } inline data_type operator () () { return Current (); } inline data_type operator * () { return Current (); } protected: void InitFrom (VectorOfPtr & ar) { this->m_stdIter = this->m_stdBegin = ar.begin (); this->m_stdEnd = ar.end (); this->m_Count = (int) ar.size (); this->m_Index = 0; } }; }