1// { dg-do assemble } 2#include<map> 3#include<iostream> 4#include<vector> 5#include<string> 6 7using namespace std; 8 9// empty parameter class with a minimal set of operations 10// if there are no weights for edges necessary 11struct Empty 12{ 13 public: 14 Empty(int=0) {} 15 bool operator<(const Empty&) const { return true;} 16}; 17inline ostream& operator<<(ostream& os, const Empty&) { return os;} 18inline istream& operator>>(istream& is, Empty& ) { return is;} 19 20 21template<class VertexType, class EdgeType> 22class 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 41template<class VertexType, class EdgeType> 42ostream& 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 "14: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 "14:no match" } no index operator 52 endN = G[i].second.end(); // { dg-error "14:no match" } no index operator 53 54 while(startN != endN) 55 { 56 os << G[(*startN).first].first << ' ' // { dg-error "20:no match" } no index operator 57 << (*startN).second << ' '; 58 ++startN; 59 } 60 os << ">\n"; 61 } 62 return os; 63} 64 65int 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} 75