OSDN Git Service

* parser.c (cp_parser_class_specifier): Set class location to that
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / g++.old-deja / g++.robertl / eb109.C
1 // { dg-do assemble  }
2 #include<map>
3 #include<iostream>
4 #include<vector>
5 #include<string>
6
7 using namespace std;
8
9 // empty parameter class with a minimal set of operations
10 // if there are no weights for edges necessary
11 struct Empty
12 {
13   public:
14     Empty(int=0) {}
15     bool operator<(const Empty&) const { return true;}
16 };
17 inline ostream& operator<<(ostream& os, const Empty&) { return os;}
18 inline istream& operator>>(istream& is, Empty& ) { return is;}
19
20
21 template<class VertexType, class EdgeType>
22 class Graph                     // { dg-message "note" } candidates
23 {
24   public:
25     // public type interface
26     typedef std::map<int, EdgeType > Successor;
27     typedef std::pair<VertexType, Successor> vertex;
28     typedef std::vector<vertex> GraphType;
29     typedef typename GraphType::iterator iterator;
30     typedef typename GraphType::const_iterator const_iterator;
31
32   // a lot of stuff deleted ....
33
34   private:
35     bool directed;
36     GraphType C;          // container
37     ostream* pOut;
38 };
39
40 // all graph-methods delet
41 template<class VertexType, class EdgeType>
42 ostream& operator<<(ostream& os, Graph<VertexType,EdgeType>& G)
43 {
44     // display of vertices with successors
45   for(int i = 0; i < G.size(); ++i)  // { dg-error "no member" } no size function
46     {
47       os << G[i].first << " <";      // { dg-error "no match" } no index operator
48
49         // The compiler does not like this line!!!!!!
50         typename Graph<VertexType, EdgeType>::Successor::iterator
51           startN = G[i].second.begin(), // { dg-error "no match" } no index operator
52           endN   = G[i].second.end();  // { dg-error "no match" } no index operator
53
54         while(startN != endN)
55         {
56             os << G[(*startN).first].first << ' ' // { dg-error "no match" } no index operator
57                << (*startN).second << ' ';
58             ++startN;
59         }
60         os << ">\n";
61     }
62     return os;
63 }
64
65 int main()
66 {
67     // no edge weighting, therefore type Empty:
68     Graph<std::string, Empty> V(true);        // { dg-error "no match" } no bool constructor
69     // ReadGraph(V, "gra1.dat");
70
71     // display of vertices with successors
72     cout << V;
73
74 }