[Bug c++/21515] problem with template and template function compilation in a namespace

bangerth at dealii dot org gcc-bugzilla@gcc.gnu.org
Thu May 12 17:49:00 GMT 2005


------- Additional Comments From bangerth at dealii dot org  2005-05-12 17:49 -------
You can't do this: 
  template<typename T> 
  std::ostream & std::operator<< (std::ostream &, a::A<T> const &); 
If you want to overload something in namespace std, you have to open that 
namespace, put the declaration in it, and close it again. If you do this 
everything is fine, i.e. like so: 
 
namespace std 
{ 
  template<typename T> 
  ostream & operator<< (ostream &, a::A<T> const &); 
} 
 
The fact that we don't reject the declaration is a bug in gcc in itself, 
for which I'll open a PR in a minute. 
 
W. 

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21515



More information about the Gcc-bugs mailing list