summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--c,cc/vector_move.cc34
1 files changed, 34 insertions, 0 deletions
diff --git a/c,cc/vector_move.cc b/c,cc/vector_move.cc
new file mode 100644
index 0000000..1167270
--- /dev/null
+++ b/c,cc/vector_move.cc
@@ -0,0 +1,34 @@
+#include <iostream>
+#include <vector>
+#include <algorithm>
+#include <iterator>
+
+using namespace std;
+
+
+struct A {
+ int d;
+
+ A(int i) : d(i) {}
+
+ A(A&& a) : d(a.d) { a.d = 0; }
+};
+
+int
+main(void)
+{
+ vector<A> a;
+ a.emplace_back(1);
+ a.emplace_back(1);
+ a.emplace_back(1);
+ vector<A> b;
+ b.emplace_back(2);
+
+ cout << a.size() << endl;
+ move(b.begin(), b.end(), back_inserter(a));
+ cout << a.size() << endl;
+ cout << b[0].d << endl;
+
+ return 0;
+}
+