Advertisement
Guest User

Untitled

a guest
Dec 9th, 2016
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. #include <iostream>
  2. #include <type_traits>
  3. #include <vector>
  4.  
  5. template< class T, typename = std::enable_if_t< std::is_same< T, std::vector< double >>::value >>
  6. std::ostream& operator<< (std::ostream& os, const T& v)
  7. {
  8. for (auto it = std::begin (v); it < std::end (v); ++it) {
  9. os << *it;
  10. if (it + 1 < std::end (v)) {
  11. os << ',';
  12. }
  13. }
  14. return os;
  15. }
  16.  
  17. int main()
  18. {
  19. std::vector< double > v (10, 1.);
  20. std::cout << v << "n";
  21. }
  22.  
  23. #include <iostream>
  24. #include <type_traits>
  25. #include <vector>
  26.  
  27. template< template< class > class T, typename = std::enable_if_t< std::is_same< T< double >, std::vector< double >>::value >>
  28. std::ostream& operator<< (std::ostream& os, const T< double >& v)
  29. {
  30. for (auto it = std::begin (v); it < std::end (v); ++it) {
  31. os << *it;
  32. if (it + 1 < std::end (v)) {
  33. os << ',';
  34. }
  35. }
  36. return os;
  37. }
  38.  
  39. int main()
  40. {
  41. std::vector< double > v (10, 1.);
  42. std::cout << v << "n";
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement