This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: [Patch]New feature to all kind of stl container.vector::data_move() returns vector::data() that can be moved,just as unique_ptr::release() to unique_ptr::get()
- From: Jonathan Wakely <jwakely dot gcc at gmail dot com>
- To: "libstdc++" <libstdc++ at gcc dot gnu dot org>
- Cc: éååå <805600352 at qq dot com>
- Date: Thu, 8 Jan 2015 11:12:04 +0000
- Subject: Re: [Patch]New feature to all kind of stl container.vector::data_move() returns vector::data() that can be moved,just as unique_ptr::release() to unique_ptr::get()
- Authentication-results: sourceware.org; auth=none
- References: <tencent_1737FA275BA843B20700F485 at qq dot com> <alpine dot DEB dot 2 dot 11 dot 1501080815100 dot 1564 at laptop-mg dot saclay dot inria dot fr>
On 8 January 2015 at 07:24, Marc Glisse wrote:
> On Thu, 8 Jan 2015, éååå wrote:
>
>> If this don't interest you because vector is used widely,let's look at
>> stringstream,since no one will forget to convert it to a string when it has
>> finished it's job:
>> stringstream ss;
>> for(int i=0;i<10000000;++i)ss<<i<<' ';
>> setString(ss.str());//you can't save this heavy copy in ss.str()
>> setString(ss.str_move());don't have to leave the heap memory of ss for
>> fear that ss's destructor will loss its job
>
>
> This should be spelled:
> std::move(ss).str()
But str() still has to return a copy. That would help if there was an
rvalue-ref-qualified version str()&&