src/work/marci/bug/ansi_pedantic_bug.cc
author alpar
Thu, 31 Mar 2005 14:04:13 +0000
changeset 1284 b941d044f87b
parent 316 d9691d0102bd
permissions -rw-r--r--
SmartGraph can also split() a node!
     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 
    12 class ListGraph {
    13 public:
    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 
    24 template<typename Graph> class GraphWrapper {
    25 protected:
    26   Graph* graph;
    27 public:
    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 
    38 template<typename Graph>
    39 class ResGraphWrapper : public GraphWrapper<Graph> {
    40 public:
    41   ResGraphWrapper(Graph& _graph) : GraphWrapper<Graph>(_graph) { }
    42 };
    43 
    44 template <typename Graph> class MaxFlow {
    45   const Graph* g;
    46   typedef ResGraphWrapper<const Graph> ResGW;
    47 public:
    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 
    55 int main(int, char **) {
    56   ListGraph G;
    57   MaxFlow<ListGraph> max_flow_test(G);
    58   max_flow_test.augmentOnShortestPath();
    59   return 0;
    60 }