summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.old-deja/g++.other/inline14.C
blob: 1bd74b4ac73795c31dd810ebe88a1dacbe0b1f57 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// { dg-do assemble  }
// Origin: Gerald Pfeifer <pfeifer@dbai.tuwien.ac.at>

#include <iostream>

struct IDENT
    {
    enum TYPE { Variable, Constant } type;

    std::ostream& printTo(std::ostream& out) const
	{
	switch (type)
	    {
	    case Variable:
		out << '_';
		break;
	    default:
		break;
	    }
	return out;
	}
    };


template <class T>
struct TC
    {
    IDENT i;

    const IDENT& getIdent() const
        {
	return i;
	}
    };

template <class T>
inline std::ostream& operator<< (std::ostream& out, const TC<T> &c)
    {
    c.getIdent().printTo(out);
    return out;
    }

void foo(const TC<IDENT> &c)
    {
    std::cerr << c 
         << ": " // This line is crucial!
         << c
         << std::endl;
    }