void _Insert(const_iterator _Where, _Iter _First, _Iter _Last, input_iterator_tag) { // insert [_First, _Last) at _Where, input iterators size_type _Off = _VIPTR(_Where) - this->_Myfirst; #if _ITERATOR_DEBUG_LEVEL == 2 if (size() < _Off) _DEBUG_ERROR("vector insert iterator outside range"); #endif /* _ITERATOR_DEBUG_LEVEL == 2 */ if (_First != _Last) { // worth doing, gather at end and rotate into place size_type _Oldsize = size(); _TRY_BEGIN for (; _First != _Last; ++_First) push_back(*_First); // append _CATCH_ALL erase(begin() + _Oldsize, end()); _RERAISE; _CATCH_END _STD rotate(begin() + _Off, begin() + _Oldsize, end()); }
void _Compat(const _Myiter& _Right) const { // test for compatible iterator pair if (this->_Getcont() == 0 || this->_Getcont() != _Right._Getcont()) { // report error _DEBUG_ERROR("vector iterators incompatible"); _SCL_SECURE_INVALID_ARGUMENT; } }
void pop_back() { // erase element at end if (empty()) _DEBUG_ERROR("vector empty before pop"); else { // erase last element _Orphan_range(this->_Mylast - 1, this->_Mylast); _Dest_val(this->_Alval, this->_Mylast - 1); --this->_Mylast; } }
iterator emplace(const_iterator _Where, _Valty&& _Val) { // insert _Val at _Where size_type _Off = _VIPTR(_Where) - this->_Myfirst; #if _ITERATOR_DEBUG_LEVEL == 2 if (size() < _Off) _DEBUG_ERROR("vector emplace iterator outside range"); #endif /* _ITERATOR_DEBUG_LEVEL == 2 */ emplace_back(_STD forward<_Valty>(_Val)); _STD rotate(begin() + _Off, end() - 1, end()); return (begin() + _Off); }
bool MyTriangle::operator==(const Figure& a) { const MyTriangle* ptr = dynamic_cast<const MyTriangle*>(&a); if (!ptr) { _DEBUG_ERROR("Попытка присвоить объекту класса MyTriangle, объект другого класса"); } else { return (*this == *ptr); } return false; }
reference operator[](size_type _Pos) { // subscript mutable sequence #if _ITERATOR_DEBUG_LEVEL == 2 if (size() <= _Pos) { // report error _DEBUG_ERROR("vector subscript out of range"); _SCL_SECURE_OUT_OF_RANGE; } #elif _ITERATOR_DEBUG_LEVEL == 1 _SCL_SECURE_VALIDATE_RANGE(_Pos < size()); #endif /* _ITERATOR_DEBUG_LEVEL */ return (*(this->_Myfirst + _Pos)); }
_Myiter& operator++() { // preincrement #if _ITERATOR_DEBUG_LEVEL == 2 if (this->_Getcont() == 0 || this->_Ptr == 0 || ((_Myvec *)this->_Getcont())->_Mylast <= this->_Ptr) { // report error _DEBUG_ERROR("vector iterator not incrementable"); _SCL_SECURE_OUT_OF_RANGE; } #elif _ITERATOR_DEBUG_LEVEL == 1 _SCL_SECURE_VALIDATE(this->_Getcont() != 0); _SCL_SECURE_VALIDATE_RANGE( this->_Ptr != 0 && this->_Ptr < ((_Myvec *)this->_Getcont())->_Mylast); #endif /* _ITERATOR_DEBUG_LEVEL */ ++this->_Ptr; return (*this); }
_Myiter& operator+=(difference_type _Off) { // increment by integer #if _ITERATOR_DEBUG_LEVEL == 2 if (this->_Getcont() == 0 || this->_Ptr + _Off < ((_Myvec *)this->_Getcont())->_Myfirst || ((_Myvec *)this->_Getcont())->_Mylast < this->_Ptr + _Off) { // report error _DEBUG_ERROR("vector iterator + offset out of range"); _SCL_SECURE_OUT_OF_RANGE; } #elif _ITERATOR_DEBUG_LEVEL == 1 _SCL_SECURE_VALIDATE(this->_Getcont() != 0); _SCL_SECURE_VALIDATE_RANGE( ((_Myvec *)this->_Getcont())->_Myfirst <= this->_Ptr + _Off && this->_Ptr + _Off <= ((_Myvec *)this->_Getcont())->_Mylast); #endif /* _ITERATOR_DEBUG_LEVEL */ _Ptr += _Off; return (*this); }
_Myiter& operator--() { // predecrement #if _ITERATOR_DEBUG_LEVEL == 2 if (this->_Getcont() == 0 || this->_Ptr == 0 || this->_Ptr <= ((_Myvec *)this->_Getcont())->_Myfirst) { // report error _DEBUG_ERROR("vector iterator not decrementable"); _SCL_SECURE_OUT_OF_RANGE; } #elif _ITERATOR_DEBUG_LEVEL == 1 _SCL_SECURE_VALIDATE(this->_Getcont() != 0); _SCL_SECURE_VALIDATE_RANGE( this->_Ptr != 0 && ((_Myvec *)this->_Getcont())->_Myfirst < this->_Ptr); #endif /* _ITERATOR_DEBUG_LEVEL */ --this->_Ptr; return (*this); }
reference operator*() const { // return designated object #if _ITERATOR_DEBUG_LEVEL == 2 if (this->_Getcont() == 0 || this->_Ptr == 0 || this->_Ptr < ((_Myvec *)this->_Getcont())->_Myfirst || ((_Myvec *)this->_Getcont())->_Mylast <= this->_Ptr) { // report error _DEBUG_ERROR("vector iterator not dereferencable"); _SCL_SECURE_OUT_OF_RANGE; } #elif _ITERATOR_DEBUG_LEVEL == 1 _SCL_SECURE_VALIDATE(this->_Getcont() != 0); _SCL_SECURE_VALIDATE_RANGE( this->_Ptr != 0 && ((_Myvec *)this->_Getcont())->_Myfirst <= this->_Ptr && this->_Ptr < ((_Myvec *)this->_Getcont())->_Mylast); #endif /* _ITERATOR_DEBUG_LEVEL */ __analysis_assume(this->_Ptr != 0); return (*this->_Ptr); }