GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
std::make_move_iterator(3) C++ Standard Libary std::make_move_iterator(3)

std::make_move_iterator - std::make_move_iterator


Defined in header <iterator>
template< class Iter > (since C++11)
std::move_iterator<Iter> make_move_iterator( Iter i ); (until C++17)
template< class Iter > (since C++17)
constexpr std::move_iterator<Iter> make_move_iterator( Iter i );


make_move_iterator is a convenience function template that constructs a
std::move_iterator for the given iterator i with the type deduced from the type of
the argument.


i - input iterator to be converted to move iterator


A std::move_iterator which can be used to move from the elements accessed through i


template< class Iter >
constexpr std::move_iterator<Iter> make_move_iterator( Iter i )
{
return std::move_iterator<Iter>(std::move(i));
}

// Run this code


#include <iostream>
#include <iomanip>
#include <list>
#include <vector>
#include <string>
#include <iterator>


auto print = [](auto const rem, auto const& seq) {
for (std::cout << rem; auto const& str : seq)
std::cout << std::quoted(str) << ' ';
std::cout << '\n';
};


int main()
{
std::list<std::string> s{"one", "two", "three"};


std::vector<std::string> v1(s.begin(), s.end()); // copy


std::vector<std::string> v2(std::make_move_iterator(s.begin()),
std::make_move_iterator(s.end())); // move


print("v1 now holds: ", v1);
print("v2 now holds: ", v2);
print("original list now holds: ", s);
}


v1 now holds: "one" "two" "three"
v2 now holds: "one" "two" "three"
original list now holds: "" "" ""


Defect reports


The following behavior-changing defect reports were applied retroactively to
previously published C++ standards.


DR Applied to Behavior as published Correct behavior
LWG 2061 C++11 make_move_iterator did not convert array made to convert
arguments to pointers


move_iterator iterator adaptor which dereferences to an rvalue reference
(C++11) (class template)
move obtains an rvalue reference
(C++11) (function template)

2022.07.31 http://cppreference.com

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.