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: éååå <805600352 at qq dot com>
- Cc: "libstdc++" <libstdc++ at gcc dot gnu dot org>
- Date: Thu, 8 Jan 2015 15:04:59 +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> <CAH6eHdRJ7XGw1m6ntK+sBtyM70yvvqUmz-LxQdPrUH8bT4SY7g at mail dot gmail dot com> <alpine dot DEB dot 2 dot 11 dot 1501081246410 dot 31658 at stedding dot saclay dot inria dot fr> <tencent_215CF4C848ACCCEF53C7F318 at qq dot com> <CAH6eHdSY1_YDN1DMRCjnFRFLsn2Ju9ScJD7VoYJFpfEkwiurTw at mail dot gmail dot com> <CAH6eHdT5nsE1j89GDQw1sppe_Dh=FyaCgYBGzj3eoEK=vD+hmw at mail dot gmail dot com> <tencent_1C9F5789024A9AE26E309110 at qq dot com>
On 8 January 2015 at 13:54, éååå wrote:
> You are right.I'm not sure of the interface.I can now only be sure of the need.
> RAII is important too.
> My opinion's good part is:make it possible for resouce moving from vector to SomeHoldingArrayDataClass,not only now just vector to another vector.I suggest data_move() only because if data_move() is at hand,stl users can easily make that possible.
> Your example can't handle resouce moving:
>> extern "C" void some_function(const int*, size_t);
>> std::vector<int> get_values(size_t n);
>> ...
>> some_function(get_values(5).data(), 5);
> what if some_function save get_values(5).data() to somewhere out of the scope?
I'm not sure what your point is, but some_function doesn't do that.