#pragma once #include "utility" #ifdef _MSC_VER #pragma pack(push, 8) #endif // _MSC_VER _STD_BEGIN // TEMPLATE CLASS reverse_bidirectional_iterator template class reverse_bidirectional_iterator : public _Bidit<_Ty, _D> { public: typedef reverse_bidirectional_iterator<_BI, _Ty, _Rt, _Pt, _D> _Myt; typedef _BI iter_type; typedef _Rt reference_type; typedef _Pt pointer_type; reverse_bidirectional_iterator() {} explicit reverse_bidirectional_iterator(_BI _X) : current(_X) {} _BI base() const {return (current); } _Rt operator*() const {_BI _Tmp = current; return (*--_Tmp); } _Pt operator->() const {return (&**this); } _Myt& operator++() {--current; return (*this); } _Myt operator++(int) {_Myt _Tmp = *this; --current; return (_Tmp); } _Myt& operator--() {++current; return (*this); } _Myt operator--(int) {_Myt _Tmp = *this; ++current; return (_Tmp); } protected: _BI current; }; template inline bool operator==(const reverse_bidirectional_iterator<_BI, _Ty, _Rt, _Pt, _D>& _X, const reverse_bidirectional_iterator<_BI, _Ty, _Rt, _Pt, _D>& _Y) {return (_X.base() == _Y.base()); } template inline bool operator!=(const reverse_bidirectional_iterator<_BI, _Ty, _Rt, _Pt, _D>& _X, const reverse_bidirectional_iterator<_BI, _Ty, _Rt, _Pt, _D>& _Y) {return (!(_X == _Y)); } // TEMPLATE CLASS back_insert_iterator_ template class back_insert_iterator_ : public iterator_ { public: typedef _C container_type; typedef typename _C::value_type value_type; explicit back_insert_iterator_(_C& _X) : container(_X) {} back_insert_iterator_<_C>& operator=( const value_type& _V) {container.push_back(_V); return (*this); } back_insert_iterator_<_C>& operator*() {return (*this); } back_insert_iterator_<_C>& operator++() {return (*this); } back_insert_iterator_<_C> operator++(int) {return (*this); } protected: _C& container; }; template inline back_insert_iterator_<_C> back_inserter(_C& _X) {return (back_insert_iterator_<_C>(_X)); } // TEMPLATE CLASS front_insert_iterator_ template class front_insert_iterator_ : public iterator_ { public: typedef _C container_type; typedef typename _C::value_type value_type; explicit front_insert_iterator_(_C& _X) : container(_X) {} front_insert_iterator_<_C>& operator=( const value_type& _V) {container.push_front(_V); return (*this); } front_insert_iterator_<_C>& operator*() {return (*this); } front_insert_iterator_<_C>& operator++() {return (*this); } front_insert_iterator_<_C> operator++(int) {return (*this); } protected: _C& container; }; template inline front_insert_iterator_<_C> front_inserter(_C& _X) {return (front_insert_iterator_<_C>(_X)); } // TEMPLATE CLASS insert_iterator_ template class insert_iterator_ : public iterator_ { public: typedef _C container_type; typedef typename _C::value_type value_type; insert_iterator_(_C& _X, typename _C::iterator_ _I) : container(_X), iter(_I) {} insert_iterator_<_C>& operator=( const value_type& _V) {iter = container.insert(iter, _V); ++iter; return (*this); } insert_iterator_<_C>& operator*() {return (*this); } insert_iterator_<_C>& operator++() {return (*this); } insert_iterator_<_C>& operator++(int) {return (*this); } protected: _C& container; typename _C::iterator_ iter; }; template inline insert_iterator_<_C> inserter(_C& _X, _XI _I) {return (insert_iterator_<_C>(_X, _C::iterator_(_I))); } // TEMPLATE CLASS istream_iterator_ template > class istream_iterator_ : public iterator_ { public: typedef _E char_type; typedef _Tr traits_type; typedef basic_istream<_E, _Tr> istream_type; istream_iterator_() : _Istr(0) {} istream_iterator_(istream_type& _I) : _Istr(&_I) {_Getval(); } const _U& operator*() const {return (_Val); } const _U *operator->() const {return (&**this); } istream_iterator_<_U, _E, _Tr>& operator++() {_Getval(); return (*this); } istream_iterator_<_U, _E, _Tr> operator++(int) {istream_iterator_<_U, _E, _Tr> _Tmp = *this; _Getval(); return (_Tmp); } bool _Equal(const istream_iterator_<_U, _E, _Tr>& _X) const {return (_Istr == _X._Istr); } protected: void _Getval() {if (_Istr != 0 && !(*_Istr >> _Val)) _Istr = 0; } istream_type *_Istr; _U _Val; }; template inline bool operator==(const istream_iterator_<_U, _E, _Tr>& _X, const istream_iterator_<_U, _E, _Tr>& _Y) {return (_X._Equal(_Y)); } template inline bool operator!=(const istream_iterator_<_U, _E, _Tr>& _X, const istream_iterator_<_U, _E, _Tr>& _Y) {return (!(_X == _Y)); } // TEMPLATE CLASS ostream_iterator_ template > class ostream_iterator_ : public iterator_ { public: typedef _U value_type; typedef _E char_type; typedef _Tr traits_type; typedef basic_ostream<_E, _Tr> ostream_type; ostream_iterator_(ostream_type& _O, const _E *_D = 0) : _Ostr(&_O), _Delim(_D) {} ostream_iterator_<_U, _E, _Tr>& operator=(const _U& _X) {*_Ostr << _X; if (_Delim != 0) *_Ostr << _Delim; return (*this); } ostream_iterator_<_U, _E, _Tr>& operator*() {return (*this); } ostream_iterator_<_U, _E, _Tr>& operator++() {return (*this); } ostream_iterator_<_U, _E, _Tr> operator++(int) {return (*this); } protected: const _E *_Delim; ostream_type *_Ostr; }; // TEMPLATE FUNCTION _Val_type template inline _Ty *_Val_type(const iterator_<_C, _Ty, _D>&) {return ((_Ty *)0); } template inline _Ty *_Val_type(const _Ty *) {return ((_Ty *)0); } // TEMPLATE FUNCTION advance_ template inline void advance_(_II& _I, _D _N) {_Advance(_I, _N, _Iter_cat(_I)); } /*template inline void _Advance(_II& _I, _D _N, input_iterator_tag) {for (; 0 < _N; --_N) ++_I; } template inline void _Advance(_FI& _I, _D _N, forward_iterator_tag) {for (; 0 < _N; --_N) ++_I; } template inline void _Advance(_BI& _I, _D _N, bidirectional_iterator_tag) {for (; 0 < _N; --_N) ++_I; for (; _N < 0; ++_N) --_I; } template inline void _Advance(_RI& _I, _D _N, random_access_iterator_tag) {_I += _N; }*/ // TEMPLATE FUNCTION _Dist_type template inline _D *_Dist_type(const iterator_<_C, _Ty, _D>&) {return ((_D *)0); } template inline ptrdiff_t *_Dist_type(const _Ty *) {return ((ptrdiff_t *)0); } _STD_END #ifdef _MSC_VER #pragma pack(pop) #endif // _MSC_VER