forked from boostorg/static_string
insert now handles when source is inside the string
This commit is contained in:
@ -1340,7 +1340,6 @@ public:
|
|||||||
return replace(pos1, n1, sv.substr(pos2, n2));
|
return replace(pos1, n1, sv.substr(pos2, n2));
|
||||||
}
|
}
|
||||||
|
|
||||||
// impl
|
|
||||||
fixed_string&
|
fixed_string&
|
||||||
replace(
|
replace(
|
||||||
size_type pos,
|
size_type pos,
|
||||||
@ -1357,7 +1356,6 @@ public:
|
|||||||
return replace(pos, n1, s, Traits::length(s));
|
return replace(pos, n1, s, Traits::length(s));
|
||||||
}
|
}
|
||||||
|
|
||||||
// impl
|
|
||||||
fixed_string&
|
fixed_string&
|
||||||
replace(
|
replace(
|
||||||
size_type pos,
|
size_type pos,
|
||||||
@ -1422,7 +1420,13 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<typename InputIterator>
|
template<typename InputIterator>
|
||||||
|
#if GENERATING_DOCUMENTATION
|
||||||
fixed_string&
|
fixed_string&
|
||||||
|
#else
|
||||||
|
typename std::enable_if<
|
||||||
|
detail::is_input_iterator<InputIterator>::value,
|
||||||
|
fixed_string&>::type
|
||||||
|
#endif
|
||||||
replace(
|
replace(
|
||||||
const_iterator i1,
|
const_iterator i1,
|
||||||
const_iterator i2,
|
const_iterator i2,
|
||||||
@ -1568,7 +1572,7 @@ public:
|
|||||||
{
|
{
|
||||||
return string_view_type(
|
return string_view_type(
|
||||||
*this).rfind(
|
*this).rfind(
|
||||||
s, pos);
|
s, pos, n);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Finds the last substring equal to the character
|
/** Finds the last substring equal to the character
|
||||||
|
@ -317,10 +317,28 @@ insert(
|
|||||||
if(size() + count > max_size())
|
if(size() + count > max_size())
|
||||||
BOOST_THROW_EXCEPTION(std::length_error{
|
BOOST_THROW_EXCEPTION(std::length_error{
|
||||||
"size() + count > max_size()"});
|
"size() + count > max_size()"});
|
||||||
Traits::move(
|
const bool inside = s <= &s_[size()] && s >= &s_[0];
|
||||||
&s_[index + count], &s_[index], size() - index);
|
if (!inside || (inside && (&s[count - 1] < &s_[index])))
|
||||||
n_ += count;
|
{
|
||||||
|
Traits::move(&s_[index + count], &s_[index], size() - index);
|
||||||
Traits::copy(&s_[index], s, count);
|
Traits::copy(&s_[index], s, count);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
const size_type offset = s - &s_[0];
|
||||||
|
Traits::move(&s_[index + count], &s_[index], size() - index);
|
||||||
|
if (offset < index)
|
||||||
|
{
|
||||||
|
const size_type diff = index - offset;
|
||||||
|
Traits::copy(&s_[index], &s_[offset], diff);
|
||||||
|
Traits::copy(&s_[index + diff], &s_[index + count], count - diff);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Traits::copy(&s_[index], &s_[index + count + offset], count);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
n_ += count;
|
||||||
term();
|
term();
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
@ -363,12 +381,13 @@ insert(
|
|||||||
BOOST_THROW_EXCEPTION(std::length_error{
|
BOOST_THROW_EXCEPTION(std::length_error{
|
||||||
"size() + count > max_size()"});
|
"size() + count > max_size()"});
|
||||||
std::size_t const index = pos - begin();
|
std::size_t const index = pos - begin();
|
||||||
Traits::move(
|
if (&*first <= &s_[size()] && &*first >= &s_[0])
|
||||||
&s_[index + count], &s_[index], size() - index);
|
return insert(index, &*first, count).begin() + index;
|
||||||
n_ += count;
|
Traits::move(&s_[index + count], &s_[index], size() - index);
|
||||||
for(auto it = begin() + index;
|
for(auto it = begin() + index;
|
||||||
first != last; ++it, ++first)
|
first != last; ++it, ++first)
|
||||||
Traits::assign(*it, *first);
|
Traits::assign(*it, *first);
|
||||||
|
n_ += count;
|
||||||
term();
|
term();
|
||||||
return begin() + index;
|
return begin() + index;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user