Advertisement
fsimen

Build error

Dec 25th, 2014
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.82 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <string>
  4.  
  5. using std::cout;
  6. using std::endl;
  7. using std::vector;
  8. using std::string;
  9.  
  10. template <class T>
  11. void print_size_and_contents(T v, string vn) {
  12.   cout << "Size of " << vn << " " << v.size() << endl;
  13.   cout << "Contents:";
  14.   for (decltype(v.size()) i : v)
  15.     cout << i << endl;
  16. }
  17.  
  18. int main(void) {
  19.   vector<int> v1;
  20.   vector<int> v2(10);
  21.   vector<int> v3(10, 42);
  22.   vector<int> v4{10};
  23.   vector<int> v5{10,42};
  24.   vector<string> v6{10};
  25.   vector<string> v7{10,"hi"};
  26.  
  27.   print_size_and_contents(v1, "v1");
  28.   print_size_and_contents(v2, "v2");
  29.   print_size_and_contents(v3, "v3");
  30.   print_size_and_contents(v4, "v4");
  31.   print_size_and_contents(v5, "v5");
  32.   print_size_and_contents  (v6, "v6");
  33.   print_size_and_contents  (v7, "v7");
  34.  
  35.  
  36.   return 0;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement