Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- _Myt& operator=(const _Myt& _Right)
- { // assign _Right
- if (this != &_Right)
- { // different, assign it
- #if _HAS_CPP0X
- if (this->_Getal() != _Right._Getal()
- && _Alty::propagate_on_container_copy_assignment::value)
- { // change allocator before copying
- _Tidy();
- this->_Change_alloc(_Right._Getal());
- }
- #endif /* _HAS_CPP0X */
- this->_Orphan_all();
- if (_Right.empty())
- clear(); // new sequence empty, erase existing sequence
- else if (_Right.size() <= size())
- { // enough elements, copy new and destroy old
- pointer _Ptr = _Copy_impl(_Right._Myfirst,
- _Right._Mylast, this->_Myfirst); // copy new
- _Destroy(_Ptr, this->_Mylast); // destroy old
- this->_Mylast = this->_Myfirst + _Right.size();
- }
- else if (_Right.size() <= capacity())
- { // enough room, copy and construct new
- pointer _Ptr = _Right._Myfirst + size();
- _Copy_impl(_Right._Myfirst,
- _Ptr, this->_Myfirst);
- this->_Mylast = _Ucopy(_Ptr, _Right._Mylast, this->_Mylast);
- }
- else
- { // not enough room, allocate new array and construct new
- if (this->_Myfirst != pointer())
- { // discard old array
- _Destroy(this->_Myfirst, this->_Mylast);
- this->_Getal().deallocate(this->_Myfirst,
- this->_Myend - this->_Myfirst);
- }
- if (_Buy(_Right.size()))
- _TRY_BEGIN
- this->_Mylast = _Ucopy(_Right._Myfirst, _Right._Mylast,
- this->_Myfirst);
- _CATCH_ALL
- _Tidy();
- _RERAISE;
- _CATCH_END
- }
- }
- return (*this);
- }
Advertisement
Add Comment
Please, Sign In to add comment