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