COIN-OR::LEMON - Graph Library

source: lemon-0.x/src/work/marci/bug/ansi_pedantic_bug.cc @ 642:e812963087f0

Last change on this file since 642:e812963087f0 was 383:0d5a628cb184, checked in by Mihaly Barasz, 21 years ago

3.4.0-asban megszuntettek a bug-ot.
Egyaltalan nem hagyta leforditani a file-t, ha nem irtunk elet "typename" es
"template" kulcsszot.
Azota viszont mar a 3.3-as is gond nelkul forditja.

File size: 1.3 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::template NodeMap<T> {
31    typedef typename Graph::template NodeMap<T> Parent;
32  public:
33    NodeMap(const GraphWrapper<Graph>& _G) : 
34      Parent(*(_G.graph)) { }
35  };
36};
37
38template<typename Graph>
39class ResGraphWrapper : public GraphWrapper<Graph> {
40public:
41  ResGraphWrapper(Graph& _graph) : GraphWrapper<Graph>(_graph) { }
42};
43
44template <typename Graph> class MaxFlow {
45  const Graph* g;
46  typedef ResGraphWrapper<const Graph> ResGW;
47public:
48  MaxFlow(const Graph& _g) : g(&_g) { }
49  void augmentOnShortestPath() {
50    ResGW res_graph(*g);
51    typename ResGW::template NodeMap<int> pred(res_graph);
52  }
53};
54
55int main(int, char **) {
56  ListGraph G;
57  MaxFlow<ListGraph> max_flow_test(G);
58  max_flow_test.augmentOnShortestPath();
59  return 0;
60}
Note: See TracBrowser for help on using the repository browser.