#pragma once #include "Iterator.Base.tlh" #include "Iterator.Sequence.tlh" #include "ListOfPtr.tlh" //----------------------------------------------------------------------------- // ListOfPtr // 偏特化 - 常量 //----------------------------------------------------------------------------- namespace Iterator { template class _LP_ConstIterator : public __SequenceIterator ::const_iterator> { typedef __SequenceIterator ::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 *; _LP_ConstIterator () : inherited () { } _LP_ConstIterator (const ListOfPtr & ar) { InitFrom (ar); } _LP_ConstIterator (const _LP_ConstIterator & from) : inherited (from) { } _LP_ConstIterator (_LP_ConstIterator && from) : inherited (from) { } public: _LP_ConstIterator & operator = (const _LP_ConstIterator & from) { inherited::operator = (from); return (*this); } _LP_ConstIterator & operator = (_LP_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 ListOfPtr & ar) { this->m_stdIter = this->m_stdBegin = ar.cbegin (); this->m_stdEnd = ar.cend (); this->m_Count = (int) ar.size (); this->m_Index = 0; } }; } //----------------------------------------------------------------------------- // ListOfPtr // 偏特化 - 变量 //----------------------------------------------------------------------------- namespace Iterator { template class _LP_Iterator : public __SequenceIterator ::iterator> { typedef __SequenceIterator ::iterator> inherited; public: // using inherited::inherited; // VC2013 编译错误 // using __Iterator >::__Iterator >; using deref_type = T; using value_type = T *; using data_type = T *; _LP_Iterator () : inherited () { } _LP_Iterator (ListOfPtr & ar) { InitFrom (ar); } _LP_Iterator (const _LP_Iterator & from) : inherited (from) { } _LP_Iterator (_LP_Iterator && from) : inherited (from) { } public: inline _LP_Iterator & operator = (const _LP_Iterator & from) { inherited::operator = (from); return (*this); } inline _LP_Iterator & operator = (_LP_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 (ListOfPtr & ar) { this->m_stdIter = this->m_stdBegin = ar.begin (); this->m_stdEnd = ar.end (); this->m_Count = (int)ar.size (); this->m_Index = 0; } }; }