This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


On Fri, 9 Jan 2015 02:52:42 am Jonathan Wakely wrote:
> >> 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?
> 
> I don't understand the question.  Why would what happen?
> 
That the vector loses ownership of its data. When the vector is destroyed it 
would release the memory with the data. What is the move method that would
take away ownership of the data if data() returned T*&& to some_function()?
-- 
Anthony Shipman                    Mamas don't let your babies 
als@iinet.net.au                   grow up to be outsourced.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]