Bug 2657248: take two, this time fix it properly!
git-svn-id: svn://svn.code.sf.net/p/loki-lib/code/trunk@993 7ec92016-0320-0410-acc4-a06ded1c099a
This commit is contained in:
parent
fc81b2a539
commit
da63cc999c
1 changed files with 16 additions and 17 deletions
|
@ -807,25 +807,24 @@ private:
|
|||
|
||||
const typename std::iterator_traits<FwdIterator>::difference_type n2 =
|
||||
std::distance(s1, s2);
|
||||
assert(n2 >= 0);
|
||||
|
||||
// Empty replacement.
|
||||
if(0 == n2)
|
||||
return;
|
||||
|
||||
assert(n2 > 0);
|
||||
|
||||
// Handle aliased replace
|
||||
static const std::less_equal<const value_type*> le =
|
||||
std::less_equal<const value_type*>();
|
||||
const bool aliased = le(&*begin(), &*s1) && le(&*s1, &*end());
|
||||
if (aliased /* && capacity() < size() - n1 + n2 */)
|
||||
// Make sure the replacement isn't empty.
|
||||
if(0 != n2)
|
||||
{
|
||||
// Aliased replace, copy to new string
|
||||
flex_string temp;
|
||||
temp.reserve(size() - n1 + n2);
|
||||
temp.append(begin(), i1).append(s1, s2).append(i2, end());
|
||||
swap(temp);
|
||||
return;
|
||||
// Handle aliased replace
|
||||
static const std::less_equal<const value_type*> le =
|
||||
std::less_equal<const value_type*>();
|
||||
const bool aliased = le(&*begin(), &*s1) && le(&*s1, &*end());
|
||||
if (aliased /* && capacity() < size() - n1 + n2 */)
|
||||
{
|
||||
// Aliased replace, copy to new string
|
||||
flex_string temp;
|
||||
temp.reserve(size() - n1 + n2);
|
||||
temp.append(begin(), i1).append(s1, s2).append(i2, end());
|
||||
swap(temp);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (n1 > n2)
|
||||
|
|
Loading…
Add table
Reference in a new issue