Advertisement
Guest User

Untitled

a guest
Apr 20th, 2014
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. void print (Container c) {
  2. for (const auto& e : c)
  3. print (e);
  4. }
  5.  
  6. // Later
  7. print (std::vector <int> {1, 2, 3, 4});
  8.  
  9. void f(double x);
  10.  
  11. template <Container C>
  12. void f(const C& c);
  13.  
  14. template <typename T>
  15. struct Container: std::false_type { };
  16.  
  17. template <typename T, size_t N>
  18. struct Container <std::array<T, N> >: std::true_type { };
  19.  
  20. template <typename T, typename A>
  21. struct Container <std::vector<T, A> >: std::true_type { };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement