Commit 335930b89478f1d46ef00af7573e18cb585d6531

Authored by Grzegorz Jabłoński
1 parent cee544e6

std::move and std::forward tests

examples11/04-vectortmpl/testvector.cpp
@@ -23,45 +23,42 @@ main () @@ -23,45 +23,42 @@ main ()
23 a.push_back(9); 23 a.push_back(9);
24 a.push_back(10); 24 a.push_back(10);
25 a.push_back(11); 25 a.push_back(11);
  26 + int arg = 13;
  27 + a.push_back(arg);
26 b=a; 28 b=a;
27 printvector (b); 29 printvector (b);
28 vector<string> c(10); 30 vector<string> c(10);
29 vector<string> d(15); 31 vector<string> d(15);
30 c[0]="ala"; 32 c[0]="ala";
31 c[9]="ma kota"; 33 c[9]="ma kota";
32 - c.push_back("ooo");  
33 - c.push_back("ooo");  
34 - c.push_back("ooo");  
35 - c.push_back("ooo");  
36 - c.push_back("ooo");  
37 - c.push_back("ooo");  
38 - c.push_back("ooo");  
39 - c.push_back("ooo");  
40 - c.push_back("ooo");  
41 - c.push_back("ooo");  
42 - c.push_back("ooo");  
43 - c.push_back("ooo");  
44 - c.push_back("ooo");  
45 - c.push_back("ooo");  
46 - c.push_back("ooo");  
47 - c.push_back("ooo");  
48 - c.push_back("ooo");  
49 - c.push_back("ooo");  
50 - c.push_back("ooo");  
51 - c.push_back("ooo");  
52 - c.push_back("ooo");  
53 - c.push_back("ooo");  
54 - c.push_back("ooo");  
55 - c.push_back("ooo");  
56 - c.push_back("ooo");  
57 - c.push_back("ooo");  
58 - c.push_back("ooo");  
59 - c.push_back("ooo");  
60 - c.push_back("ooo");  
61 - c.push_back("ooo");  
62 - c.push_back("ooo");  
63 - c.push_back("ooo");  
64 - 34 +
  35 + const char* long_string="long_string_that_will_not_use_SSO";
  36 +
  37 + c.push_back(long_string);
  38 + c.push_back(long_string);
  39 + c.push_back(long_string);
  40 + c.push_back(long_string);
  41 + c.push_back(long_string);
  42 + c.push_back(long_string);
  43 + c.push_back(long_string);
  44 + c.push_back(long_string);
  45 + c.push_back(long_string);
  46 + c.push_back(long_string);
  47 + c.push_back(long_string);
  48 + c.push_back(long_string);
  49 + c.push_back(long_string);
  50 + c.push_back(long_string);
  51 + c.push_back(long_string);
  52 + c.push_back(long_string);
  53 + c.push_back(long_string);
  54 + c.push_back(long_string);
  55 + c.push_back(long_string);
  56 + c.push_back(long_string);
  57 + c.push_back(long_string);
  58 +
  59 + string l(long_string);
  60 + c.push_back(l);
  61 + c.emplace_back(long_string);
65 cout << "About to assign vector" << endl; 62 cout << "About to assign vector" << endl;
66 d=c; 63 d=c;
67 cout << "Vector assigned" << endl; 64 cout << "Vector assigned" << endl;
examples11/04-vectortmpl/vector.h
@@ -147,6 +147,7 @@ public: @@ -147,6 +147,7 @@ public:
147 // cout << "push_back with rvalue argument" << endl; 147 // cout << "push_back with rvalue argument" << endl;
148 resize_before_push(); 148 resize_before_push();
149 new (data + size) C(std::move(s)); 149 new (data + size) C(std::move(s));
  150 +// new (data + size) C(s);
150 ++size; 151 ++size;
151 return *(data + size); 152 return *(data + size);
152 } 153 }