Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <QVector>
- #include <QTextStream>
- #include <vector>
- #include <list>
- #include <deque>
- struct MoveTest
- {
- int i;
- MoveTest() {}
- MoveTest(const MoveTest& other) {QTextStream(stdout) << "constr copy" << endl;}
- MoveTest(MoveTest &&other) {QTextStream(stdout) << "constr move" << endl;}
- ~MoveTest() {}
- inline MoveTest& operator= (const MoveTest& other) {QTextStream(stdout) << "copy" << endl;}
- inline MoveTest& operator= (MoveTest &&other) {QTextStream(stdout) << "move" << endl;}
- };
- int main(int argc, char *argv[])
- {
- QTextStream(stdout) << "std::move:" << endl;
- MoveTest t1;
- MoveTest t2(std::move(t1));
- t1 = std::move(t2);
- QTextStream(stdout) << "\nQVector:" << endl;
- QVector<MoveTest> qmTest(5);
- qmTest.insert(qmTest.begin(), MoveTest());
- QTextStream(stdout) << "\nstd::vector:" << endl;
- std::vector<MoveTest> mTest(5);
- mTest.emplace(mTest.begin());
- QTextStream(stdout) << "\nstd::list:" << endl;
- std::list<MoveTest> mlTest(5);
- mlTest.emplace(mlTest.begin());
- QTextStream(stdout) << "\nstd::deque:" << endl;
- std::deque<MoveTest> mdTest(5);
- mdTest.emplace(mdTest.begin(), MoveTest());
- return 0;
- }
- ------------------------------------------------------------------
- std::move:
- constr move
- move
- QVector:
- constr copy
- constr copy
- constr copy
- constr copy
- constr copy
- constr copy
- copy
- copy
- copy
- copy
- copy
- copy
- std::vector:
- constr copy
- constr copy
- constr copy
- constr copy
- constr copy
- std::list:
- std::deque:
- constr move
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement