diff options
Diffstat (limited to 'boost/container/string.hpp')
-rw-r--r-- | boost/container/string.hpp | 57 |
1 files changed, 27 insertions, 30 deletions
diff --git a/boost/container/string.hpp b/boost/container/string.hpp index e5ec287cf8..7399223904 100644 --- a/boost/container/string.hpp +++ b/boost/container/string.hpp @@ -111,8 +111,7 @@ class basic_string_base ~basic_string_base() { if(!this->is_short()){ - this->deallocate_block(); - this->is_short(true); + this->deallocate(this->priv_long_addr(), this->priv_long_storage()); } } @@ -131,15 +130,14 @@ class basic_string_base long_t(const long_t &other) { - this->is_short = other.is_short; + this->is_short = false; length = other.length; storage = other.storage; start = other.start; } - long_t &operator =(const long_t &other) + long_t &operator= (const long_t &other) { - this->is_short = other.is_short; length = other.length; storage = other.storage; start = other.start; @@ -165,8 +163,7 @@ class basic_string_base static const size_type MinInternalBufferChars = 8; static const size_type AlignmentOfValueType = alignment_of<value_type>::value; - static const size_type ShortDataOffset = - container_detail::ct_rounded_size<sizeof(short_header), AlignmentOfValueType>::value; + static const size_type ShortDataOffset = ((sizeof(short_header)-1)/AlignmentOfValueType+1)*AlignmentOfValueType; static const size_type ZeroCostInternalBufferChars = (sizeof(long_t) - ShortDataOffset)/sizeof(value_type); static const size_type UnalignedFinalInternalBufferChars = @@ -421,21 +418,19 @@ class basic_string_base } else{ short_t short_backup(this->members_.m_repr.short_repr()); - long_t long_backup (other.members_.m_repr.long_repr()); + this->members_.m_repr.short_repr().~short_t(); + ::new(&this->members_.m_repr.long_repr()) long_t(other.members_.m_repr.long_repr()); other.members_.m_repr.long_repr().~long_t(); - ::new(&this->members_.m_repr.long_repr()) long_t; - this->members_.m_repr.long_repr() = long_backup; - other.members_.m_repr.short_repr() = short_backup; + ::new(&other.members_.m_repr.short_repr()) short_t(short_backup); } } else{ if(other.is_short()){ short_t short_backup(other.members_.m_repr.short_repr()); - long_t long_backup (this->members_.m_repr.long_repr()); + other.members_.m_repr.short_repr().~short_t(); + ::new(&other.members_.m_repr.long_repr()) long_t(this->members_.m_repr.long_repr()); this->members_.m_repr.long_repr().~long_t(); - ::new(&other.members_.m_repr.long_repr()) long_t; - other.members_.m_repr.long_repr() = long_backup; - this->members_.m_repr.short_repr() = short_backup; + ::new(&this->members_.m_repr.short_repr()) short_t(short_backup); } else{ boost::adl_move_swap(this->members_.m_repr.long_repr(), other.members_.m_repr.long_repr()); @@ -1289,9 +1284,7 @@ class basic_string template <class InputIter> basic_string& assign(InputIter first, InputIter last #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED) - , typename container_detail::enable_if_c - < !container_detail::is_convertible<InputIter, size_type>::value - >::type * = 0 + , typename container_detail::disable_if_convertible<InputIter, size_type>::type * = 0 #endif ) { @@ -1438,9 +1431,10 @@ class basic_string template <class InputIter> iterator insert(const_iterator p, InputIter first, InputIter last #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED) - , typename container_detail::enable_if_c - < !container_detail::is_convertible<InputIter, size_type>::value - && container_detail::is_input_iterator<InputIter>::value + , typename container_detail::disable_if_or + < void + , container_detail::is_convertible<InputIter, size_type> + , container_detail::is_not_input_iterator<InputIter> >::type * = 0 #endif ) @@ -1455,9 +1449,10 @@ class basic_string #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED) template <class ForwardIter> iterator insert(const_iterator p, ForwardIter first, ForwardIter last - , typename container_detail::enable_if_c - < !container_detail::is_convertible<ForwardIter, size_type>::value - && !container_detail::is_input_iterator<ForwardIter>::value + , typename container_detail::disable_if_or + < void + , container_detail::is_convertible<ForwardIter, size_type> + , container_detail::is_input_iterator<ForwardIter> >::type * = 0 ) { @@ -1829,9 +1824,10 @@ class basic_string template <class InputIter> basic_string& replace(const_iterator i1, const_iterator i2, InputIter j1, InputIter j2 #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED) - , typename container_detail::enable_if_c - < !container_detail::is_convertible<InputIter, size_type>::value - && container_detail::is_input_iterator<InputIter>::value + , typename container_detail::disable_if_or + < void + , container_detail::is_convertible<InputIter, size_type> + , container_detail::is_input_iterator<InputIter> >::type * = 0 #endif ) @@ -1850,9 +1846,10 @@ class basic_string #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED) template <class ForwardIter> basic_string& replace(const_iterator i1, const_iterator i2, ForwardIter j1, ForwardIter j2 - , typename container_detail::enable_if_c - < !container_detail::is_convertible<ForwardIter, size_type>::value - && !container_detail::is_input_iterator<ForwardIter>::value + , typename container_detail::disable_if_or + < void + , container_detail::is_convertible<ForwardIter, size_type> + , container_detail::is_not_input_iterator<ForwardIter> >::type * = 0 ) { |