forked from boostorg/container
Use directly boost::movelib::to_raw_pointer/iterator_to_raw_pointer
This commit is contained in:
@@ -35,7 +35,7 @@
|
||||
#include <boost/container/detail/min_max.hpp>
|
||||
#include <boost/container/detail/mpl.hpp>
|
||||
#include <boost/container/detail/next_capacity.hpp>
|
||||
#include <boost/container/detail/to_raw_pointer.hpp>
|
||||
#include <boost/move/detail/to_raw_pointer.hpp>
|
||||
#include <boost/container/detail/version_type.hpp>
|
||||
#include <boost/container/detail/type_traits.hpp>
|
||||
#include <boost/container/detail/minimal_char_traits_header.hpp>
|
||||
@@ -308,14 +308,14 @@ class basic_string_base
|
||||
{
|
||||
allocator_traits_type::construct
|
||||
( this->alloc()
|
||||
, container_detail::to_raw_pointer(p)
|
||||
, boost::movelib::to_raw_pointer(p)
|
||||
, value
|
||||
);
|
||||
}
|
||||
|
||||
void destroy(pointer p, size_type n)
|
||||
{
|
||||
value_type *raw_p = container_detail::to_raw_pointer(p);
|
||||
value_type *raw_p = boost::movelib::to_raw_pointer(p);
|
||||
for(; n--; ++raw_p){
|
||||
allocator_traits_type::destroy( this->alloc(), raw_p);
|
||||
}
|
||||
@@ -325,7 +325,7 @@ class basic_string_base
|
||||
{
|
||||
allocator_traits_type::destroy
|
||||
( this->alloc()
|
||||
, container_detail::to_raw_pointer(p)
|
||||
, boost::movelib::to_raw_pointer(p)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1158,8 +1158,8 @@ class basic_string
|
||||
size_type long_storage = this->priv_long_storage();
|
||||
size_type long_size = this->priv_long_size();
|
||||
//Shrink from allocated buffer to the internal one, including trailing null
|
||||
Traits::copy( container_detail::to_raw_pointer(this->priv_short_addr())
|
||||
, container_detail::to_raw_pointer(long_addr)
|
||||
Traits::copy( boost::movelib::to_raw_pointer(this->priv_short_addr())
|
||||
, boost::movelib::to_raw_pointer(long_addr)
|
||||
, long_size+1);
|
||||
this->is_short(true);
|
||||
this->alloc().deallocate(long_addr, long_storage);
|
||||
@@ -1492,7 +1492,7 @@ class basic_string
|
||||
{
|
||||
size_type n = static_cast<size_type>(last - first);
|
||||
this->reserve(n);
|
||||
CharT* ptr = container_detail::to_raw_pointer(this->priv_addr());
|
||||
CharT* ptr = boost::movelib::to_raw_pointer(this->priv_addr());
|
||||
Traits::copy(ptr, first, n);
|
||||
this->priv_construct_null(ptr + n);
|
||||
this->priv_size(n);
|
||||
@@ -1511,7 +1511,7 @@ class basic_string
|
||||
{
|
||||
size_type cur = 0;
|
||||
const pointer addr = this->priv_addr();
|
||||
CharT *ptr = container_detail::to_raw_pointer(addr);
|
||||
CharT *ptr = boost::movelib::to_raw_pointer(addr);
|
||||
const size_type old_size = this->priv_size();
|
||||
while (first != last && cur != old_size) {
|
||||
Traits::assign(*ptr, *first);
|
||||
@@ -1570,7 +1570,7 @@ class basic_string
|
||||
size_type len = container_detail::min_value(n, str_size - pos2);
|
||||
if (sz > this->max_size() - len)
|
||||
throw_length_error("basic_string::insert max_size() exceeded");
|
||||
const CharT *beg_ptr = container_detail::to_raw_pointer(s.begin()) + pos2;
|
||||
const CharT *beg_ptr = boost::movelib::to_raw_pointer(s.begin()) + pos2;
|
||||
const CharT *end_ptr = beg_ptr + len;
|
||||
this->insert(this->priv_addr() + pos1, beg_ptr, end_ptr);
|
||||
return *this;
|
||||
@@ -1730,10 +1730,10 @@ class basic_string
|
||||
pointer_past_last, pointer_past_last);
|
||||
|
||||
this->priv_size(old_size+n);
|
||||
Traits::move(const_cast<CharT*>(container_detail::to_raw_pointer(p + n)),
|
||||
container_detail::to_raw_pointer(p),
|
||||
Traits::move(const_cast<CharT*>(boost::movelib::to_raw_pointer(p + n)),
|
||||
boost::movelib::to_raw_pointer(p),
|
||||
(elems_after - n) + 1);
|
||||
this->priv_copy(first, last, const_cast<CharT*>(container_detail::to_raw_pointer(p)));
|
||||
this->priv_copy(first, last, const_cast<CharT*>(boost::movelib::to_raw_pointer(p)));
|
||||
}
|
||||
else {
|
||||
ForwardIter mid = first;
|
||||
@@ -1746,7 +1746,7 @@ class basic_string
|
||||
(p, const_iterator(old_start + old_length + 1),
|
||||
old_start + newer_size);
|
||||
this->priv_size(newer_size + elems_after);
|
||||
this->priv_copy(first, mid, const_cast<CharT*>(container_detail::to_raw_pointer(p)));
|
||||
this->priv_copy(first, mid, const_cast<CharT*>(boost::movelib::to_raw_pointer(p)));
|
||||
}
|
||||
}
|
||||
else{
|
||||
@@ -1773,9 +1773,9 @@ class basic_string
|
||||
else{
|
||||
//value_type is POD, so backwards expansion is much easier
|
||||
//than with vector<T>
|
||||
value_type * const oldbuf = container_detail::to_raw_pointer(old_start);
|
||||
value_type * const newbuf = container_detail::to_raw_pointer(new_start);
|
||||
const value_type *const pos = container_detail::to_raw_pointer(p);
|
||||
value_type * const oldbuf = boost::movelib::to_raw_pointer(old_start);
|
||||
value_type * const newbuf = boost::movelib::to_raw_pointer(new_start);
|
||||
const value_type *const pos = boost::movelib::to_raw_pointer(p);
|
||||
const size_type before = pos - oldbuf;
|
||||
|
||||
//First move old data
|
||||
@@ -1847,10 +1847,10 @@ class basic_string
|
||||
iterator erase(const_iterator p) BOOST_NOEXCEPT_OR_NOTHROW
|
||||
{
|
||||
// The move includes the terminating null.
|
||||
CharT * const ptr = const_cast<CharT*>(container_detail::to_raw_pointer(p));
|
||||
CharT * const ptr = const_cast<CharT*>(boost::movelib::to_raw_pointer(p));
|
||||
const size_type old_size = this->priv_size();
|
||||
Traits::move(ptr,
|
||||
container_detail::to_raw_pointer(p + 1),
|
||||
boost::movelib::to_raw_pointer(p + 1),
|
||||
old_size - (p - this->priv_addr()));
|
||||
this->priv_size(old_size-1);
|
||||
return iterator(ptr);
|
||||
@@ -1866,12 +1866,12 @@ class basic_string
|
||||
//! the other elements being erased. If no such element exists, end() is returned.
|
||||
iterator erase(const_iterator first, const_iterator last) BOOST_NOEXCEPT_OR_NOTHROW
|
||||
{
|
||||
CharT * f = const_cast<CharT*>(container_detail::to_raw_pointer(first));
|
||||
CharT * f = const_cast<CharT*>(boost::movelib::to_raw_pointer(first));
|
||||
if (first != last) { // The move includes the terminating null.
|
||||
const size_type num_erased = last - first;
|
||||
const size_type old_size = this->priv_size();
|
||||
Traits::move(f,
|
||||
container_detail::to_raw_pointer(last),
|
||||
boost::movelib::to_raw_pointer(last),
|
||||
(old_size + 1)-(last - this->priv_addr()));
|
||||
const size_type new_length = old_size - num_erased;
|
||||
this->priv_size(new_length);
|
||||
@@ -2059,11 +2059,11 @@ class basic_string
|
||||
{
|
||||
const size_type len = static_cast<size_type>(i2 - i1);
|
||||
if (len >= n) {
|
||||
Traits::assign(const_cast<CharT*>(container_detail::to_raw_pointer(i1)), n, c);
|
||||
Traits::assign(const_cast<CharT*>(boost::movelib::to_raw_pointer(i1)), n, c);
|
||||
erase(i1 + n, i2);
|
||||
}
|
||||
else {
|
||||
Traits::assign(const_cast<CharT*>(container_detail::to_raw_pointer(i1)), len, c);
|
||||
Traits::assign(const_cast<CharT*>(boost::movelib::to_raw_pointer(i1)), len, c);
|
||||
insert(i2, n - len, c);
|
||||
}
|
||||
return *this;
|
||||
@@ -2088,7 +2088,7 @@ class basic_string
|
||||
)
|
||||
{
|
||||
for ( ; i1 != i2 && j1 != j2; ++i1, ++j1){
|
||||
Traits::assign(*const_cast<CharT*>(container_detail::to_raw_pointer(i1)), *j1);
|
||||
Traits::assign(*const_cast<CharT*>(boost::movelib::to_raw_pointer(i1)), *j1);
|
||||
}
|
||||
|
||||
if (j1 == j2)
|
||||
@@ -2111,13 +2111,13 @@ class basic_string
|
||||
difference_type n = boost::container::iterator_distance(j1, j2);
|
||||
const difference_type len = i2 - i1;
|
||||
if (len >= n) {
|
||||
this->priv_copy(j1, j2, const_cast<CharT*>(container_detail::to_raw_pointer(i1)));
|
||||
this->priv_copy(j1, j2, const_cast<CharT*>(boost::movelib::to_raw_pointer(i1)));
|
||||
this->erase(i1 + n, i2);
|
||||
}
|
||||
else {
|
||||
ForwardIter m = j1;
|
||||
boost::container::iterator_advance(m, len);
|
||||
this->priv_copy(j1, m, const_cast<CharT*>(container_detail::to_raw_pointer(i1)));
|
||||
this->priv_copy(j1, m, const_cast<CharT*>(boost::movelib::to_raw_pointer(i1)));
|
||||
this->insert(i2, m, j2);
|
||||
}
|
||||
return *this;
|
||||
@@ -2166,7 +2166,7 @@ class basic_string
|
||||
if (pos > this->size())
|
||||
throw_out_of_range("basic_string::copy out of range position");
|
||||
const size_type len = container_detail::min_value(n, this->size() - pos);
|
||||
Traits::copy(s, container_detail::to_raw_pointer(this->priv_addr() + pos), len);
|
||||
Traits::copy(s, boost::movelib::to_raw_pointer(this->priv_addr() + pos), len);
|
||||
return len;
|
||||
}
|
||||
|
||||
@@ -2195,7 +2195,7 @@ class basic_string
|
||||
//!
|
||||
//! <b>Complexity</b>: constant time.
|
||||
const CharT* c_str() const BOOST_NOEXCEPT_OR_NOTHROW
|
||||
{ return container_detail::to_raw_pointer(this->priv_addr()); }
|
||||
{ return boost::movelib::to_raw_pointer(this->priv_addr()); }
|
||||
|
||||
//! <b>Requires</b>: The program shall not alter any of the values stored in the character array.
|
||||
//!
|
||||
@@ -2203,13 +2203,13 @@ class basic_string
|
||||
//!
|
||||
//! <b>Complexity</b>: constant time.
|
||||
const CharT* data() const BOOST_NOEXCEPT_OR_NOTHROW
|
||||
{ return container_detail::to_raw_pointer(this->priv_addr()); }
|
||||
{ return boost::movelib::to_raw_pointer(this->priv_addr()); }
|
||||
|
||||
//! <b>Returns</b>: A pointer p such that p + i == &operator[](i) for each i in [0,size()].
|
||||
//!
|
||||
//! <b>Complexity</b>: constant time.
|
||||
CharT* data() BOOST_NOEXCEPT_OR_NOTHROW
|
||||
{ return container_detail::to_raw_pointer(this->priv_addr()); }
|
||||
{ return boost::movelib::to_raw_pointer(this->priv_addr()); }
|
||||
|
||||
#ifndef BOOST_CONTAINER_TEMPLATED_CONVERSION_OPERATOR_BROKEN
|
||||
//! <b>Returns</b>: a string_view to the characters in the string.
|
||||
@@ -2272,8 +2272,8 @@ class basic_string
|
||||
const pointer addr = this->priv_addr();
|
||||
pointer finish = addr + this->priv_size();
|
||||
const const_iterator result =
|
||||
std::search(container_detail::to_raw_pointer(addr + pos),
|
||||
container_detail::to_raw_pointer(finish),
|
||||
std::search(boost::movelib::to_raw_pointer(addr + pos),
|
||||
boost::movelib::to_raw_pointer(finish),
|
||||
s, s + n, Eq_traits<Traits>());
|
||||
return result != finish ? result - begin() : npos;
|
||||
}
|
||||
@@ -2804,8 +2804,8 @@ class basic_string
|
||||
{
|
||||
const difference_type n1 = l1 - f1;
|
||||
const difference_type n2 = l2 - f2;
|
||||
const int cmp = Traits::compare(container_detail::to_raw_pointer(f1),
|
||||
container_detail::to_raw_pointer(f2),
|
||||
const int cmp = Traits::compare(boost::movelib::to_raw_pointer(f1),
|
||||
boost::movelib::to_raw_pointer(f2),
|
||||
container_detail::min_value(n1, n2));
|
||||
return cmp != 0 ? cmp : (n1 < n2 ? -1 : (n1 > n2 ? 1 : 0));
|
||||
}
|
||||
@@ -2826,8 +2826,8 @@ class basic_string
|
||||
real_cap = long_size+1;
|
||||
const pointer ret = this->allocation_command(allocate_new, long_size+1, real_cap, reuse);
|
||||
//Copy and update
|
||||
Traits::copy( container_detail::to_raw_pointer(ret)
|
||||
, container_detail::to_raw_pointer(this->priv_long_addr())
|
||||
Traits::copy( boost::movelib::to_raw_pointer(ret)
|
||||
, boost::movelib::to_raw_pointer(this->priv_long_addr())
|
||||
, long_size+1);
|
||||
this->priv_long_addr(ret);
|
||||
this->priv_storage(real_cap);
|
||||
|
||||
Reference in New Issue
Block a user