C++ Iterator Library make move iterator

C++ Iterator Library make move iterator
返回C++,Iterator,Library,make,move常用代码示例代码片段
#include <iostream>     
#include <iterator>     
#include <vector>       
#include <string>       
#include <algorithm>    

int main () {
   std::vector<std::string> foo (3);
   std::vector<std::string> bar {"tutorialspont","com","india"};

   std::copy ( make_move_iterator(bar.begin()),
               make_move_iterator(bar.end()),
               foo.begin() );

   // bar now contains unspecified values; clear it:
   bar.clear();

   std::cout << "foo:";
   for (std::string& x : foo) std::cout << ' ' << x;
   std::cout << '\n';

   return 0;
}
原文链接:https://rumenz.com/examples/Cpp11/cplusplus-iterator-library-make-move-iterator.html

【Linux常用命令速查手册】关注【入门小站】,后台回复 「1001」 自取。

点击下面标题即可获取对应PDF资料
↑回到顶部↑
入门小站 @2018