Last change
on this file since 383:0d5a628cb184 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
|
Rev | Line | |
---|
[315] | 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 | |
---|
[383] | 30 | template<typename T> class NodeMap : public Graph::template NodeMap<T> { |
---|
| 31 | typedef typename Graph::template NodeMap<T> Parent; |
---|
[315] | 32 | public: |
---|
| 33 | NodeMap(const GraphWrapper<Graph>& _G) : |
---|
[383] | 34 | Parent(*(_G.graph)) { } |
---|
[315] | 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); |
---|
[383] | 51 | typename ResGW::template NodeMap<int> pred(res_graph); |
---|
[315] | 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 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.