Difference between revisions of "cpp/algorithm/move"
From cppreference.com
m (Text replace - "===Equivalent function===" to "===Possible implementation===") |
|||
Line 59: | Line 59: | ||
v.emplace_back(f, 3); | v.emplace_back(f, 3); | ||
std::list<std::thread> l; | std::list<std::thread> l; | ||
− | // copy() would not compile}} | + | // copy() would not compile,because the thread`s parent is noncopyable}} |
[[cpp/algorithm/move#top | <span class="mw-geshi cpp source-cpp">std::move</span>]]{{cpp|(v.begin(), v.end(), std::back_inserter(l)); | [[cpp/algorithm/move#top | <span class="mw-geshi cpp source-cpp">std::move</span>]]{{cpp|(v.begin(), v.end(), std::back_inserter(l)); |
Revision as of 00:40, 4 April 2012
Template:cpp/algorithm/sidebar Template:ddcl list begin <tr class="t-dsc-header">
<td>Defined in header
</td>
<algorithm>
<td></td> <td></td> </tr> <tr class="t-dcl ">
<td >template< class InputIterator, class OutputIterator >
OutputIterator move( InputIterator first, InputIterator last, OutputIterator d_first );
</td>
OutputIterator move( InputIterator first, InputIterator last, OutputIterator d_first );
<td class="t-dcl-nopad"> </td> <td > (since C++11) </td> </tr> Template:ddcl list end
Moves the elements in the range [first, last)
, to another range beginning at d_first
.
Contents |
Parameters
first, last | - | the range of elements to move |
d_first | - | the beginning of the destination range. If d_first is within [first, last) , Template:cpp must be used instead of std::move.
|
Return value
Output iterator to the element past the last element moved (Template:cpp)
Complexity
Exactly last - first
move assignments.
Possible implementation
Example
The following code moves threads handles (which themselves are not copyable) from one container to another.
Output:
thread 1 ended thread 2 ended thread 3 ended