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) { Q_UNUSED(other); QTextStream(stdout) << "constr copy" << endl;}
- MoveTest(MoveTest &&other) { Q_UNUSED(other); QTextStream(stdout) << "constr move" << endl;}
- ~MoveTest() {}
- inline MoveTest& operator= (const MoveTest& other) { Q_UNUSED(other); QTextStream(stdout) << "copy" << endl; return *this;}
- inline MoveTest& operator= (MoveTest &&other) { Q_UNUSED(other); QTextStream(stdout) << "move" << endl; return *this;}
- };
- int main()
- {
- 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.insert(mTest.begin(), MoveTest());
- QTextStream(stdout) << "\nstd::list:" << endl;
- std::list<MoveTest> mlTest(5);
- mlTest.insert(mlTest.begin(), MoveTest());
- QTextStream(stdout) << "\nstd::deque:" << endl;
- std::deque<MoveTest> mdTest(5);
- mdTest.insert(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 move
- constr copy
- constr copy
- constr copy
- constr copy
- constr copy
- std::list:
- constr move
- std::deque:
- constr move
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement