Skip to content

Instantly share code, notes, and snippets.

@adiog
Created November 5, 2017 19:27
Show Gist options
  • Save adiog/45556ff408248f31d2990695aee138ad to your computer and use it in GitHub Desktop.
Save adiog/45556ff408248f31d2990695aee138ad to your computer and use it in GitHub Desktop.
make_move_iterator
#include <algorithm>
#include <iostream>
#include <iterator>
#include <ostream>
#include <string>
#include <vector>
using namespace std;
int main() {
vector<string> dst;
{
vector<string> src;
src.push_back("The Motion Picture");
src.push_back("The Wrath Of Khan");
src.push_back("The Search For Spock");
src.push_back("The Voyage Home");
src.push_back("The Final Frontier");
src.push_back("The Undiscovered Country");
src.push_back("Generations");
src.push_back("First Contact");
src.push_back("Insurrection");
src.push_back("Nemesis");
src.push_back("Star Trek");
copy_if(
make_move_iterator(src.begin()),
make_move_iterator(src.end()),
back_inserter(dst),
[](const string& s) {
return s != "The Final Frontier";
}
);
}
for (auto i = dst.begin(); i != dst.end(); ++i) {
cout << *i << endl;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment