mirror of
https://github.com/boostorg/container.git
synced 2025-08-02 14:04:26 +02:00
Fixes #9648, (string construction optimization)
This commit is contained in:
@@ -932,6 +932,7 @@ use [*Boost.Container]? There are several reasons for that:
|
|||||||
|
|
||||||
* Fixed bugs:
|
* Fixed bugs:
|
||||||
* [@https://svn.boost.org/trac/boost/ticket/9338 #9338: ['"VS2005 compiler errors in swap() definition after including container/memory_util.hpp"]].
|
* [@https://svn.boost.org/trac/boost/ticket/9338 #9338: ['"VS2005 compiler errors in swap() definition after including container/memory_util.hpp"]].
|
||||||
|
* [@https://svn.boost.org/trac/boost/ticket/9648 #9648: ['"string construction optimization - char_traits::copy could be used ..."]].
|
||||||
|
|
||||||
[endsect]
|
[endsect]
|
||||||
|
|
||||||
|
@@ -1247,6 +1247,20 @@ class basic_string
|
|||||||
basic_string& assign(size_type n, CharT c)
|
basic_string& assign(size_type n, CharT c)
|
||||||
{ return this->assign(cvalue_iterator(c, n), cvalue_iterator()); }
|
{ return this->assign(cvalue_iterator(c, n), cvalue_iterator()); }
|
||||||
|
|
||||||
|
//! <b>Effects</b>: Equivalent to assign(basic_string(first, last)).
|
||||||
|
//!
|
||||||
|
//! <b>Returns</b>: *this
|
||||||
|
basic_string& assign(const CharT* first, const CharT* last)
|
||||||
|
{
|
||||||
|
size_type n = static_cast<size_type>(last - first);
|
||||||
|
this->reserve(n);
|
||||||
|
CharT* ptr = container_detail::to_raw_pointer(this->priv_addr());
|
||||||
|
Traits::copy(ptr, first, n);
|
||||||
|
this->priv_construct_null(ptr + n);
|
||||||
|
this->priv_size(n);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
//! <b>Effects</b>: Equivalent to assign(basic_string(first, last)).
|
//! <b>Effects</b>: Equivalent to assign(basic_string(first, last)).
|
||||||
//!
|
//!
|
||||||
//! <b>Returns</b>: *this
|
//! <b>Returns</b>: *this
|
||||||
|
Reference in New Issue
Block a user