[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()

Jonathan Wakely jwakely.gcc@gmail.com
Thu Jan 8 11:12:00 GMT 2015


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()&&



More information about the Libstdc++ mailing list