fork download
  1. #include <iostream>
  2.  
  3. template<typename T> class Foo;
  4.  
  5. template <typename T>
  6. std::ostream& operator<< (std::ostream& o, const Foo<T>& x);
  7.  
  8. template<typename T>
  9. class Foo {
  10. public:
  11. Foo(T const& value = T());
  12. friend std::ostream& operator<< <> (std::ostream& o, const Foo<T>& x);
  13. //friend std::ostream& ::operator<< (std::ostream& o, const Foo<T>& x);
  14. private:
  15. T value_;
  16. };
  17.  
  18. template<typename T>
  19. Foo<T>::Foo(T const& value )
  20. : value_(value)
  21. { }
  22.  
  23. template<typename T>
  24. std::ostream& operator<< (std::ostream& o, const Foo<T>& x)
  25. { return o << x.value_; }
  26.  
  27. int main()
  28. {
  29. Foo<int> rhs(2);
  30. std::cout << rhs;
  31. }
Success #stdin #stdout 0.01s 2724KB
stdin
Standard input is empty
stdout
2