OutputIt move( InputIt first, InputIt last,
ForwardIt2 move( ExecutionPolicy&& policy,
ForwardIt1 first, ForwardIt1 last,
1) Moves the elements in the range [
first,
last)
, to another range beginning at d_first, starting from first and proceeding to last. After this operation the elements in the moved-from range will still contain valid values of the appropriate type, but not necessarily the same values as before the move.
2) Same as (1), but executed according to policy.
This overload participates in overload resolution only if all following conditions are satisfied:
If d_first is within the range [
first,
last)
, the behavior is undefined. In this case, std::move_backward may be used instead.
The iterator to the element past the last element moved.
[edit] ComplexityExactly std::distance(first, last) move assignments.
[edit] ExceptionsThe overload with a template parameter named ExecutionPolicy
reports errors as follows:
ExecutionPolicy
is one of the standard policies, std::terminate is called. For any other ExecutionPolicy
, the behavior is implementation-defined.template<class InputIt, class OutputIt> OutputIt move(InputIt first, InputIt last, OutputIt d_first) { for (; first != last; ++d_first, ++first) *d_first = std::move(*first); return d_first; }[edit] Notes
When moving overlapping ranges, std::move
is appropriate when moving to the left (beginning of the destination range is outside the source range) while std::move_backward is appropriate when moving to the right (end of the destination range is outside the source range).
The following code moves thread objects (which themselves are not copyable) from one container to another.
Output:
thread 1 ended thread 2 ended thread 3 ended[edit] See also moves a range of elements to a new location in backwards order
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4