COIN-OR::LEMON - Graph Library

source: lemon-0.x/src/work/marci/bug/ansi_pedantic_bug.cc @ 320:190ecba15b33

Last change on this file since 320:190ecba15b33 was 316:d9691d0102bd, checked in by marci, 21 years ago

bug

File size: 1.2 KB
Line 
1// -*- c++ -*-
2//compile it with
3//g++ -ansi -pedantic
4//and with
5//g++
6//I did with g++ ver 3.0.4, suse 8.0
7//If the template is removed from NodeMap, then it works well.
8//athos@cs.elte.hu
9//klao@cs.elte.hu
10//marci@cs.elte.hu
11
12class ListGraph {
13public:
14  ListGraph() { }
15
16  template <typename T> class NodeMap {
17    const ListGraph& G;
18  public:
19    NodeMap(const ListGraph& _G) : G(_G) { }
20  };
21
22};
23
24template<typename Graph> class GraphWrapper {
25protected:
26  Graph* graph;
27public:
28  GraphWrapper(Graph& _graph) : graph(&_graph) { }
29 
30  template<typename T> class NodeMap : public Graph::NodeMap<T> {
31  public:
32    NodeMap(const GraphWrapper<Graph>& _G) : 
33      Graph::NodeMap<T>(*(_G.graph)) { }
34  };
35};
36
37template<typename Graph>
38class ResGraphWrapper : public GraphWrapper<Graph> {
39public:
40  ResGraphWrapper(Graph& _graph) : GraphWrapper<Graph>(_graph) { }
41};
42
43template <typename Graph> class MaxFlow {
44  const Graph* g;
45  typedef ResGraphWrapper<const Graph> ResGW;
46public:
47  MaxFlow(const Graph& _g) : g(&_g) { }
48  void augmentOnShortestPath() {
49    ResGW res_graph(*g);
50    typename ResGW::NodeMap<int> pred(res_graph);
51  }
52};
53
54int main(int, char **) {
55  ListGraph G;
56  MaxFlow<ListGraph> max_flow_test(G);
57  max_flow_test.augmentOnShortestPath();
58  return 0;
59}
Note: See TracBrowser for help on using the repository browser.