View | Details | Raw Unified | Return to bug 40518 | Differences between
and this patch

Collapse All | Expand All | Context: (Patch / File /
)

(-)include/bits/basic_string.h (-16 / +13 lines)
 Lines 197-208    Link Here 
197
197
198
	void
198
	void
199
	_M_set_length_and_sharable(size_type __n)
199
	_M_set_length_and_sharable(size_type __n)
200
	{ 
200
	{
201
	  this->_M_set_sharable();  // One reference.
201
#ifndef _GLIBCXX_FULLY_DYNAMIC_STRING
202
	  this->_M_length = __n;
202
	  if (__builtin_expect(this != &_S_empty_rep(), false))
203
	  traits_type::assign(this->_M_refdata()[__n], _S_terminal);
203
#endif
204
	  // grrr. (per 21.3.4)
204
	    {
205
	  // You cannot leave those LWG people alone for a second.
205
	      this->_M_set_sharable();  // One reference.
206
	      this->_M_length = __n;
207
	      traits_type::assign(this->_M_refdata()[__n], _S_terminal);
208
	      // grrr. (per 21.3.4)
209
	      // You cannot leave those LWG people alone for a second.
210
	    }
206
	}
211
	}
207
212
208
	_CharT*
213
	_CharT*
 Lines 1226-1241    Link Here 
1226
       *  The value of the string doesn't change if an error is thrown.
1231
       *  The value of the string doesn't change if an error is thrown.
1227
      */
1232
      */
1228
      iterator
1233
      iterator
1229
      erase(iterator __first, iterator __last)
1234
      erase(iterator __first, iterator __last);
1230
      {
1235
 
1231
	_GLIBCXX_DEBUG_PEDASSERT(__first >= _M_ibegin() && __first <= __last
1232
				 && __last <= _M_iend());
1233
        const size_type __pos = __first - _M_ibegin();
1234
	_M_mutate(__pos, __last - __first, size_type(0));
1235
	_M_rep()->_M_set_leaked();
1236
	return iterator(_M_data() + __pos);
1237
      }
1238
1239
      /**
1236
      /**
1240
       *  @brief  Replace characters with value from another string.
1237
       *  @brief  Replace characters with value from another string.
1241
       *  @param pos  Index of first character to replace.
1238
       *  @param pos  Index of first character to replace.
(-)include/bits/basic_string.tcc (+20 lines)
 Lines 386-391    Link Here 
386
     }
386
     }
387
387
388
   template<typename _CharT, typename _Traits, typename _Alloc>
388
   template<typename _CharT, typename _Traits, typename _Alloc>
389
     typename basic_string<_CharT, _Traits, _Alloc>::iterator
390
     basic_string<_CharT, _Traits, _Alloc>::
391
     erase(iterator __first, iterator __last)
392
     {
393
       _GLIBCXX_DEBUG_PEDASSERT(__first >= _M_ibegin() && __first <= __last
394
				&& __last <= _M_iend());
395
396
       const size_type __size = __last - __first;
397
       if (__size)
398
	 {
399
	   const size_type __pos = __first - _M_ibegin();
400
	   _M_mutate(__pos, __size, size_type(0));
401
	   _M_rep()->_M_set_leaked();
402
	   return iterator(_M_data() + __pos);
403
	 }
404
       else
405
	 return __first;
406
     }
407
408
   template<typename _CharT, typename _Traits, typename _Alloc>
389
     basic_string<_CharT, _Traits, _Alloc>&
409
     basic_string<_CharT, _Traits, _Alloc>&
390
     basic_string<_CharT, _Traits, _Alloc>::
410
     basic_string<_CharT, _Traits, _Alloc>::
391
     replace(size_type __pos, size_type __n1, const _CharT* __s,
411
     replace(size_type __pos, size_type __n1, const _CharT* __s,

Return to bug 40518