src/work/marci/ansi_pedantic_bug.cc
changeset 315 7b97540cd743
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/work/marci/ansi_pedantic_bug.cc	Thu Apr 08 12:03:49 2004 +0000
     1.3 @@ -0,0 +1,59 @@
     1.4 +// -*- c++ -*-
     1.5 +//compile it with 
     1.6 +//g++ -ansi -pedantic
     1.7 +//and with 
     1.8 +//g++
     1.9 +//I did with g++ ver 3.0.4, suse 8.0
    1.10 +//If the template is removed from NodeMap, then it works well.
    1.11 +//athos@cs.elte.hu
    1.12 +//klao@cs.elte.hu
    1.13 +//marci@cs.elte.hu
    1.14 +
    1.15 +class ListGraph {
    1.16 +public:
    1.17 +  ListGraph() { }
    1.18 +
    1.19 +  template <typename T> class NodeMap {
    1.20 +    const ListGraph& G; 
    1.21 +  public:
    1.22 +    NodeMap(const ListGraph& _G) : G(_G) { }
    1.23 +  };
    1.24 +
    1.25 +};
    1.26 +
    1.27 +template<typename Graph> class GraphWrapper {
    1.28 +protected:
    1.29 +  Graph* graph;
    1.30 +public:
    1.31 +  GraphWrapper(Graph& _graph) : graph(&_graph) { }
    1.32 + 
    1.33 +  template<typename T> class NodeMap : public Graph::NodeMap<T> { 
    1.34 +  public:
    1.35 +    NodeMap(const GraphWrapper<Graph>& _G) :  
    1.36 +      Graph::NodeMap<T>(*(_G.graph)) { }
    1.37 +  };
    1.38 +};
    1.39 +
    1.40 +template<typename Graph>
    1.41 +class ResGraphWrapper : public GraphWrapper<Graph> {
    1.42 +public:
    1.43 +  ResGraphWrapper(Graph& _graph) : GraphWrapper<Graph>(_graph) { }
    1.44 +};
    1.45 +
    1.46 +template <typename Graph> class MaxFlow {
    1.47 +  const Graph* g;
    1.48 +  typedef ResGraphWrapper<const Graph> ResGW;
    1.49 +public:
    1.50 +  MaxFlow(const Graph& _g) : g(&_g) { }
    1.51 +  void augmentOnShortestPath() {
    1.52 +    ResGW res_graph(*g);
    1.53 +    typename ResGW::NodeMap<int> pred(res_graph); 
    1.54 +  }
    1.55 +};
    1.56 +
    1.57 +int main(int, char **) {
    1.58 +  ListGraph G;
    1.59 +  MaxFlow<ListGraph> max_flow_test(G);
    1.60 +  max_flow_test.augmentOnShortestPath();
    1.61 +  return 0;
    1.62 +}