1.1 --- a/src/work/marci/ansi_pedantic_bug.cc Thu Apr 08 12:03:49 2004 +0000
1.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
1.3 @@ -1,59 +0,0 @@
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 -}
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2.2 +++ b/src/work/marci/bug/ansi_pedantic_bug.cc Thu Apr 08 13:11:58 2004 +0000
2.3 @@ -0,0 +1,59 @@
2.4 +// -*- c++ -*-
2.5 +//compile it with
2.6 +//g++ -ansi -pedantic
2.7 +//and with
2.8 +//g++
2.9 +//I did with g++ ver 3.0.4, suse 8.0
2.10 +//If the template is removed from NodeMap, then it works well.
2.11 +//athos@cs.elte.hu
2.12 +//klao@cs.elte.hu
2.13 +//marci@cs.elte.hu
2.14 +
2.15 +class ListGraph {
2.16 +public:
2.17 + ListGraph() { }
2.18 +
2.19 + template <typename T> class NodeMap {
2.20 + const ListGraph& G;
2.21 + public:
2.22 + NodeMap(const ListGraph& _G) : G(_G) { }
2.23 + };
2.24 +
2.25 +};
2.26 +
2.27 +template<typename Graph> class GraphWrapper {
2.28 +protected:
2.29 + Graph* graph;
2.30 +public:
2.31 + GraphWrapper(Graph& _graph) : graph(&_graph) { }
2.32 +
2.33 + template<typename T> class NodeMap : public Graph::NodeMap<T> {
2.34 + public:
2.35 + NodeMap(const GraphWrapper<Graph>& _G) :
2.36 + Graph::NodeMap<T>(*(_G.graph)) { }
2.37 + };
2.38 +};
2.39 +
2.40 +template<typename Graph>
2.41 +class ResGraphWrapper : public GraphWrapper<Graph> {
2.42 +public:
2.43 + ResGraphWrapper(Graph& _graph) : GraphWrapper<Graph>(_graph) { }
2.44 +};
2.45 +
2.46 +template <typename Graph> class MaxFlow {
2.47 + const Graph* g;
2.48 + typedef ResGraphWrapper<const Graph> ResGW;
2.49 +public:
2.50 + MaxFlow(const Graph& _g) : g(&_g) { }
2.51 + void augmentOnShortestPath() {
2.52 + ResGW res_graph(*g);
2.53 + typename ResGW::NodeMap<int> pred(res_graph);
2.54 + }
2.55 +};
2.56 +
2.57 +int main(int, char **) {
2.58 + ListGraph G;
2.59 + MaxFlow<ListGraph> max_flow_test(G);
2.60 + max_flow_test.augmentOnShortestPath();
2.61 + return 0;
2.62 +}