forked from boostorg/static_string
Added unchecked insertion
This commit is contained in:
@ -423,28 +423,6 @@ insert(
|
||||
return curr_data + index;
|
||||
}
|
||||
|
||||
template<std::size_t N, typename CharT, typename Traits>
|
||||
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
||||
auto
|
||||
basic_static_string<N, CharT, Traits>::
|
||||
insert(
|
||||
const_iterator pos,
|
||||
std::initializer_list<CharT> ilist) BOOST_STATIC_STRING_NO_EXCEPTIONS_NOEXCEPT ->
|
||||
iterator
|
||||
{
|
||||
const auto curr_size = size();
|
||||
const auto curr_data = data();
|
||||
const auto index = pos - curr_data;
|
||||
BOOST_STATIC_STRING_THROW_IF(
|
||||
index > curr_size, std::out_of_range{"index > size()"});
|
||||
BOOST_STATIC_STRING_THROW_IF(
|
||||
ilist.size() > max_size() - curr_size, std::length_error{"count > max_size() - size()"});
|
||||
Traits::move(&curr_data[index + ilist.size()], &curr_data[index], curr_size - index + 1);
|
||||
detail::copy_with_traits<Traits>(ilist.begin(), ilist.end(), &curr_data[index]);
|
||||
this->set_size(curr_size + ilist.size());
|
||||
return curr_data + index;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
template<std::size_t N, typename CharT, typename Traits>
|
||||
@ -962,6 +940,29 @@ replace_unchecked(
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<std::size_t N, typename CharT, typename Traits>
|
||||
BOOST_STATIC_STRING_CPP14_CONSTEXPR
|
||||
auto
|
||||
basic_static_string<N, CharT, Traits>::
|
||||
insert_unchecked(
|
||||
size_type index,
|
||||
const CharT* s,
|
||||
size_type count) BOOST_STATIC_STRING_NO_EXCEPTIONS_NOEXCEPT ->
|
||||
basic_static_string<N, CharT, Traits>&
|
||||
{
|
||||
const auto curr_data = data();
|
||||
const auto curr_size = size();
|
||||
BOOST_STATIC_STRING_THROW_IF(
|
||||
index > curr_size, std::out_of_range{"index > size()"});
|
||||
BOOST_STATIC_STRING_THROW_IF(
|
||||
count > max_size() - size(),
|
||||
std::length_error{"count > max_size() - size()"});
|
||||
Traits::move(&curr_data[index + count], &curr_data[index], curr_size - index + 1);
|
||||
Traits::copy(&curr_data[index], s, count);
|
||||
this->set_size(curr_size + count);
|
||||
return *this;
|
||||
}
|
||||
|
||||
// to_static_string
|
||||
|
||||
static_string<std::numeric_limits<int>::digits10 + 1>
|
||||
|
Reference in New Issue
Block a user