#include #include using namespace std; class countcopy{ public: countcopy(int val = 0) { v = val; } countcopy(const countcopy &cm) { v = cm.v; numcopies++; } countcopy &operator=(const countcopy &cm) { if (&cm != this) { v = cm.v; numassigns++; } return *this; } int v; static int numcopies,numassigns,nummoves,nummassigns; }; int countcopy::numcopies = 0; int countcopy::numassigns = 0; int countcopy::nummoves = 0; int countcopy::nummassigns = 0; int main(int argc, char **argv) { vector > >v; for(int i=0;i<100;i++) { vector > a; for(int j=0;j<100;j++) { vector b; for(int k=0;k<100;k++) b.push_back(countcopy(i+j+k)); a.push_back(b); } v.push_back(a); } cout << "# copies: " << countcopy::numcopies << endl; cout << "# assigns: " << countcopy::numassigns<< endl; cout << "# moves: " << countcopy::nummoves << endl; cout << "# move-assigns: " << countcopy::nummassigns<< endl; return 0; }