1 // { dg-do assemble  }
2 // Origin: Gerald Pfeifer <pfeifer@dbai.tuwien.ac.at>
3 
4 #include <iostream>
5 
6 struct IDENT
7     {
8     enum TYPE { Variable, Constant } type;
9 
printToIDENT10     std::ostream& printTo(std::ostream& out) const
11 	{
12 	switch (type)
13 	    {
14 	    case Variable:
15 		out << '_';
16 		break;
17 	    default:
18 		break;
19 	    }
20 	return out;
21 	}
22     };
23 
24 
25 template <class T>
26 struct TC
27     {
28     IDENT i;
29 
getIdentTC30     const IDENT& getIdent() const
31         {
32 	return i;
33 	}
34     };
35 
36 template <class T>
37 inline std::ostream& operator<< (std::ostream& out, const TC<T> &c)
38     {
39     c.getIdent().printTo(out);
40     return out;
41     }
42 
foo(const TC<IDENT> & c)43 void foo(const TC<IDENT> &c)
44     {
45     std::cerr << c
46          << ": " // This line is crucial!
47          << c
48          << std::endl;
49     }
50