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

Anthony Shipman als@iinet.net.au
Thu Jan 8 15:19:00 GMT 2015


On Fri, 9 Jan 2015 12:36:05 am Jonathan Wakely wrote:
> That is a poor interface, which can cause currently working code to leak
>  memory.
> 
> extern "C" void some_function(const int*, size_t);
> std::vector<int> get_values(size_t n);
> ...
> some_function(get_values(5).data(), 5);
> 
> Today this works correctly. With your suggestion the call to data()
> would release ownership of the memory and it would never be freed.
> 
Why would this happen? Is there some sort of implied operator=(&&) for
the int* type?
-- 
Anthony Shipman                    Mamas don't let your babies 
als@iinet.net.au                   grow up to be outsourced.



More information about the Libstdc++ mailing list