1.1 --- a/lemon/graph_reader.h Wed Oct 05 13:17:42 2005 +0000
1.2 +++ b/lemon/graph_reader.h Wed Oct 05 13:18:51 2005 +0000
1.3 @@ -122,8 +122,7 @@
1.4 ///
1.5 /// Construct a new GraphReader. It reads into the given graph
1.6 /// and it uses the given reader as the default skipper.
1.7 - GraphReader(std::istream& _is,
1.8 - typename SmartParameter<Graph>::Type _graph,
1.9 + GraphReader(std::istream& _is, Graph& _graph,
1.10 const DefaultSkipper& _skipper = DefaultSkipper())
1.11 : reader(new LemonReader(_is)), own_reader(true), skipper(_skipper),
1.12 nodeset_reader(*reader, _graph, std::string(), skipper),
1.13 @@ -137,8 +136,7 @@
1.14 ///
1.15 /// Construct a new GraphReader. It reads into the given graph
1.16 /// and it uses the given reader as the default skipper.
1.17 - GraphReader(const std::string& _filename,
1.18 - typename SmartParameter<Graph>::Type _graph,
1.19 + GraphReader(const std::string& _filename, Graph& _graph,
1.20 const DefaultSkipper& _skipper = DefaultSkipper())
1.21 : reader(new LemonReader(_filename)), own_reader(true),
1.22 skipper(_skipper),
1.23 @@ -153,8 +151,7 @@
1.24 ///
1.25 /// Construct a new GraphReader. It reads into the given graph
1.26 /// and it uses the given reader as the default skipper.
1.27 - GraphReader(LemonReader& _reader,
1.28 - typename SmartParameter<Graph>::Type _graph,
1.29 + GraphReader(LemonReader& _reader, Graph& _graph,
1.30 const DefaultSkipper& _skipper = DefaultSkipper())
1.31 : reader(_reader), own_reader(false), skipper(_skipper),
1.32 nodeset_reader(*reader, _graph, std::string(), skipper),
2.1 --- a/lemon/lemon_reader.h Wed Oct 05 13:17:42 2005 +0000
2.2 +++ b/lemon/lemon_reader.h Wed Oct 05 13:18:51 2005 +0000
2.3 @@ -36,6 +36,8 @@
2.4 #include <lemon/utility.h>
2.5 #include <lemon/bits/item_reader.h>
2.6
2.7 +#include <lemon/xy.h>
2.8 +
2.9 #include <lemon/concept_check.h>
2.10 #include <lemon/concept/maps.h>
2.11
2.12 @@ -94,38 +96,108 @@
2.13 }
2.14 };
2.15
2.16 - template <typename M1, typename M2>
2.17 - class WriteComposeMap {
2.18 + template <typename Map>
2.19 + struct Ref { typedef Map& Type; };
2.20 + template <typename Map>
2.21 + struct Arg { typedef Map& Type; };
2.22 +
2.23 + template <typename Graph, typename Map>
2.24 + class ForwardComposeMap {
2.25 public:
2.26 - typedef True NeedCopy;
2.27 + typedef typename Graph::UndirEdge Key;
2.28 + typedef typename Map::Value Value;
2.29 +
2.30 + ForwardComposeMap(const Graph& _graph, typename Arg<Map>::Type _map)
2.31 + : graph(_graph), map(_map) {}
2.32
2.33 - typedef typename M2::Key Key;
2.34 - typedef typename M1::Value Value;
2.35 -
2.36 - WriteComposeMap(typename SmartParameter<M1>::Type _m1, const M2& _m2)
2.37 - : m1(_m1), m2(_m2) {}
2.38 -
2.39 - void set(const Key& key, const Value& value) {
2.40 - m1.set(m2[key], value);
2.41 + void set(const Key& key, const Value& val) {
2.42 + map.set(graph.direct(key, true), val);
2.43 }
2.44
2.45 private:
2.46 -
2.47 - typename SmartReference<M1>::Type m1;
2.48 - typename SmartConstReference<M2>::Type m2;
2.49 -
2.50 + typename Ref<Map>::Type map;
2.51 + const Graph& graph;
2.52 };
2.53
2.54 - template <typename M1, typename M2>
2.55 - WriteComposeMap<M1, M2> writeComposeMap(M1& m1, const M2& m2) {
2.56 - return WriteComposeMap<M1, M2>(m1, m2);
2.57 + template <typename Graph, typename Map>
2.58 + ForwardComposeMap<Graph, Map>
2.59 + forwardComposeMap(const Graph& graph, const Map& map) {
2.60 + return ForwardComposeMap<Graph, Map>(graph, map);
2.61 }
2.62
2.63 - template <typename M1, typename M2>
2.64 - WriteComposeMap<M1, M2> writeComposeMap(const M1& m1, const M2& m2) {
2.65 - return WriteComposeMap<M1, M2>(m1, m2);
2.66 + template <typename Graph, typename Map>
2.67 + ForwardComposeMap<Graph, Map>
2.68 + forwardComposeMap(const Graph& graph, Map& map) {
2.69 + return ForwardComposeMap<Graph, Map>(graph, map);
2.70 }
2.71 -
2.72 +
2.73 + template <typename Graph, typename Map>
2.74 + class BackwardComposeMap {
2.75 + public:
2.76 + typedef typename Graph::UndirEdge Key;
2.77 + typedef typename Map::Value Value;
2.78 +
2.79 + BackwardComposeMap(const Graph& _graph, typename Arg<Map>::Type _map)
2.80 + : graph(_graph), map(_map) {}
2.81 +
2.82 + void set(const Key& key, const Value& val) {
2.83 + map.set(graph.direct(key, false), val);
2.84 + }
2.85 +
2.86 + private:
2.87 + typename Ref<Map>::Type map;
2.88 + const Graph& graph;
2.89 + };
2.90 +
2.91 +
2.92 + template <typename Graph, typename Map>
2.93 + BackwardComposeMap<Graph, Map>
2.94 + backwardComposeMap(const Graph& graph, const Map& map) {
2.95 + return BackwardComposeMap<Graph, Map>(graph, map);
2.96 + }
2.97 +
2.98 + template <typename Graph, typename Map>
2.99 + BackwardComposeMap<Graph, Map>
2.100 + backwardComposeMap(const Graph& graph, Map& map) {
2.101 + return BackwardComposeMap<Graph, Map>(graph, map);
2.102 + }
2.103 +
2.104 + template <typename Graph, typename Map>
2.105 + struct Ref<ForwardComposeMap<Graph, Map> > {
2.106 + typedef ForwardComposeMap<Graph, Map> Type;
2.107 + };
2.108 + template <typename Graph, typename Map>
2.109 + struct Arg<ForwardComposeMap<Graph, Map> > {
2.110 + typedef const ForwardComposeMap<Graph, Map>& Type;
2.111 + };
2.112 +
2.113 + template <typename Graph, typename Map>
2.114 + struct Ref<BackwardComposeMap<Graph, Map> > {
2.115 + typedef BackwardComposeMap<Graph, Map> Type;
2.116 + };
2.117 + template <typename Graph, typename Map>
2.118 + struct Arg<BackwardComposeMap<Graph, Map> > {
2.119 + typedef const BackwardComposeMap<Graph, Map>& Type;
2.120 + };
2.121 +
2.122 + template <typename Map>
2.123 + struct Ref<XMap<Map> > {
2.124 + typedef XMap<Map> Type;
2.125 + };
2.126 + template <typename Map>
2.127 + struct Arg<XMap<Map> > {
2.128 + typedef const XMap<Map>& Type;
2.129 + };
2.130 +
2.131 + template <typename Map>
2.132 + struct Ref<YMap<Map> > {
2.133 + typedef YMap<Map> Type;
2.134 + };
2.135 + template <typename Map>
2.136 + struct Arg<YMap<Map> > {
2.137 + typedef const YMap<Map>& Type;
2.138 + };
2.139 +
2.140 }
2.141
2.142 /// \ingroup io_group
2.143 @@ -432,11 +504,11 @@
2.144 typedef _Map Map;
2.145 typedef std::map<Value, Item, _reader_bits::Less<Value> > Inverse;
2.146
2.147 - typename SmartReference<Map>::Type map;
2.148 + typename _reader_bits::Ref<Map>::Type map;
2.149 Reader reader;
2.150 Inverse inverse;
2.151
2.152 - MapReaderInverter(typename SmartParameter<Map>::Type _map,
2.153 + MapReaderInverter(typename _reader_bits::Arg<Map>::Type _map,
2.154 const Reader& _reader)
2.155 : map(_map), reader(_reader) {}
2.156
2.157 @@ -526,10 +598,10 @@
2.158 typedef typename Reader::Value Value;
2.159 typedef _Item Item;
2.160
2.161 - typename SmartReference<Map>::Type map;
2.162 + typename _reader_bits::Ref<Map>::Type map;
2.163 Reader reader;
2.164
2.165 - MapReader(typename SmartParameter<Map>::Type _map,
2.166 + MapReader(typename _reader_bits::Arg<Map>::Type _map,
2.167 const Reader& _reader)
2.168 : map(_map), reader(_reader) {}
2.169
2.170 @@ -659,7 +731,7 @@
2.171 /// add the readed nodes to the given Graph. The reader will read
2.172 /// the section when the \c section_id and the \c _id are the same.
2.173 NodeSetReader(LemonReader& _reader,
2.174 - typename SmartParameter<Graph>::Type _graph,
2.175 + Graph& _graph,
2.176 const std::string& _id = std::string(),
2.177 const DefaultSkipper& _skipper = DefaultSkipper())
2.178 : Parent(_reader), graph(_graph), id(_id), skipper(_skipper) {}
2.179 @@ -688,14 +760,14 @@
2.180 NodeSetReader& readNodeMap(std::string name, Map& map) {
2.181 return _readMap<
2.182 typename Traits::template Reader<typename Map::Value>, Map,
2.183 - typename SmartParameter<Map>::Type>(name, map);
2.184 + typename _reader_bits::Arg<Map>::Type>(name, map);
2.185 }
2.186
2.187 template <typename Map>
2.188 NodeSetReader& readNodeMap(std::string name, const Map& map) {
2.189 return _readMap<
2.190 typename Traits::template Reader<typename Map::Value>, Map,
2.191 - typename SmartParameter<Map>::Type>(name, map);
2.192 + typename _reader_bits::Arg<Map>::Type>(name, map);
2.193 }
2.194
2.195 /// \brief Add a new node map reader command for the reader.
2.196 @@ -704,14 +776,14 @@
2.197 template <typename Reader, typename Map>
2.198 NodeSetReader& readNodeMap(std::string name, Map& map,
2.199 const Reader& reader = Reader()) {
2.200 - return _readMap<Reader, Map, typename SmartParameter<Map>::Type>
2.201 + return _readMap<Reader, Map, typename _reader_bits::Arg<Map>::Type>
2.202 (name, map, reader);
2.203 }
2.204
2.205 template <typename Reader, typename Map>
2.206 NodeSetReader& readNodeMap(std::string name, const Map& map,
2.207 const Reader& reader = Reader()) {
2.208 - return _readMap<Reader, Map, typename SmartParameter<Map>::Type>
2.209 + return _readMap<Reader, Map, typename _reader_bits::Arg<Map>::Type>
2.210 (name, map, reader);
2.211 }
2.212
2.213 @@ -817,7 +889,7 @@
2.214 typedef std::map<std::string, ReaderBase<Node>*> MapReaders;
2.215 MapReaders readers;
2.216
2.217 - typename SmartReference<Graph>::Type graph;
2.218 + Graph& graph;
2.219 std::string id;
2.220 SkipReader<Node, DefaultSkipper> skipper;
2.221
2.222 @@ -867,7 +939,7 @@
2.223 /// \c edgset_id are the same.
2.224 template <typename NodeIdReader>
2.225 EdgeSetReader(LemonReader& _reader,
2.226 - typename SmartParameter<Graph>::Type _graph,
2.227 + Graph& _graph,
2.228 const NodeIdReader& _nodeIdReader,
2.229 const std::string& _id = std::string(),
2.230 const DefaultSkipper& _skipper = DefaultSkipper())
2.231 @@ -898,14 +970,14 @@
2.232 EdgeSetReader& readEdgeMap(std::string name, Map& map) {
2.233 return _readMap<
2.234 typename Traits::template Reader<typename Map::Value>, Map,
2.235 - typename SmartParameter<Map>::Type>(name, map);
2.236 + typename _reader_bits::Arg<Map>::Type>(name, map);
2.237 }
2.238
2.239 template <typename Map>
2.240 EdgeSetReader& readEdgeMap(std::string name, const Map& map) {
2.241 return _readMap<
2.242 typename Traits::template Reader<typename Map::Value>, Map,
2.243 - typename SmartParameter<Map>::Type>(name, map);
2.244 + typename _reader_bits::Arg<Map>::Type>(name, map);
2.245 }
2.246
2.247 /// \brief Add a new edge map reader command for the reader.
2.248 @@ -915,14 +987,14 @@
2.249 EdgeSetReader& readEdgeMap(std::string name, Map& map,
2.250 const Reader& reader = Reader()) {
2.251 return _readMap<Reader, Map,
2.252 - typename SmartParameter<Map>::Type>(name, map, reader);
2.253 + typename _reader_bits::Arg<Map>::Type>(name, map, reader);
2.254 }
2.255
2.256 template <typename Reader, typename Map>
2.257 EdgeSetReader& readEdgeMap(std::string name, const Map& map,
2.258 const Reader& reader = Reader()) {
2.259 return _readMap<Reader, Map,
2.260 - typename SmartParameter<Map>::Type>(name, map, reader);
2.261 + typename _reader_bits::Arg<Map>::Type>(name, map, reader);
2.262 }
2.263
2.264 private:
2.265 @@ -1032,7 +1104,7 @@
2.266 typedef std::map<std::string, ReaderBase<Edge>*> MapReaders;
2.267 MapReaders readers;
2.268
2.269 - typename SmartReference<Graph>::Type graph;
2.270 + Graph& graph;
2.271 std::string id;
2.272 SkipReader<Edge, DefaultSkipper> skipper;
2.273
2.274 @@ -1089,7 +1161,7 @@
2.275 /// \c _id and the \c undiredgset_id are the same.
2.276 template <typename NodeIdReader>
2.277 UndirEdgeSetReader(LemonReader& _reader,
2.278 - typename SmartParameter<Graph>::Type _graph,
2.279 + Graph& _graph,
2.280 const NodeIdReader& _nodeIdReader,
2.281 const std::string& _id = std::string(),
2.282 const DefaultSkipper& _skipper = DefaultSkipper())
2.283 @@ -1120,14 +1192,14 @@
2.284 UndirEdgeSetReader& readUndirEdgeMap(std::string name, Map& map) {
2.285 return _readMap<
2.286 typename Traits::template Reader<typename Map::Value>, Map,
2.287 - typename SmartParameter<Map>::Type>(name, map);
2.288 + typename _reader_bits::Arg<Map>::Type>(name, map);
2.289 }
2.290
2.291 template <typename Map>
2.292 UndirEdgeSetReader& readUndirEdgeMap(std::string name, const Map& map) {
2.293 return _readMap<
2.294 typename Traits::template Reader<typename Map::Value>, Map,
2.295 - typename SmartParameter<Map>::Type>(name, map);
2.296 + typename _reader_bits::Arg<Map>::Type>(name, map);
2.297 }
2.298
2.299 /// \brief Add a new undirected edge map reader command for the reader.
2.300 @@ -1136,14 +1208,14 @@
2.301 template <typename Reader, typename Map>
2.302 UndirEdgeSetReader& readUndirEdgeMap(std::string name, Map& map,
2.303 const Reader& reader = Reader()) {
2.304 - return _readMap<Reader, Map, typename SmartParameter<Map>::Type>
2.305 + return _readMap<Reader, Map, typename _reader_bits::Arg<Map>::Type>
2.306 (name, map, reader);
2.307 }
2.308
2.309 template <typename Reader, typename Map>
2.310 UndirEdgeSetReader& readUndirEdgeMap(std::string name, const Map& map,
2.311 const Reader& reader = Reader()) {
2.312 - return _readMap<Reader, Map, typename SmartParameter<Map>::Type >
2.313 + return _readMap<Reader, Map, typename _reader_bits::Arg<Map>::Type >
2.314 (name, map, reader);
2.315 }
2.316
2.317 @@ -1189,14 +1261,14 @@
2.318 UndirEdgeSetReader& readEdgeMap(std::string name, Map& map) {
2.319 return _readDirMap<
2.320 typename Traits::template Reader<typename Map::Value>, Map,
2.321 - typename SmartParameter<Map>::Type>(name, map);
2.322 + typename _reader_bits::Arg<Map>::Type>(name, map);
2.323 }
2.324
2.325 template <typename Map>
2.326 UndirEdgeSetReader& readEdgeMap(std::string name, const Map& map) {
2.327 return _readDirMap<
2.328 typename Traits::template Reader<typename Map::Value>, Map,
2.329 - typename SmartParameter<Map>::Type>(name, map);
2.330 + typename _reader_bits::Arg<Map>::Type>(name, map);
2.331 }
2.332
2.333 /// \brief Add a new directed edge map reader command for the reader.
2.334 @@ -1205,14 +1277,14 @@
2.335 template <typename Reader, typename Map>
2.336 UndirEdgeSetReader& readEdgeMap(std::string name, Map& map,
2.337 const Reader& reader = Reader()) {
2.338 - return _readDirMap<Reader, Map, typename SmartParameter<Map>::Type>
2.339 + return _readDirMap<Reader, Map, typename _reader_bits::Arg<Map>::Type>
2.340 (name, map, reader);
2.341 }
2.342
2.343 template <typename Reader, typename Map>
2.344 UndirEdgeSetReader& readEdgeMap(std::string name, const Map& map,
2.345 const Reader& reader = Reader()) {
2.346 - return _readDirMap<Reader, Map, typename SmartParameter<Map>::Type>
2.347 + return _readDirMap<Reader, Map, typename _reader_bits::Arg<Map>::Type>
2.348 (name, map, reader);
2.349 }
2.350
2.351 @@ -1224,9 +1296,9 @@
2.352 checkConcept<_reader_bits::ItemReader<typename Map::Value>, Reader>();
2.353 checkConcept<concept::WriteMap<Edge, typename Map::Value>, Map>();
2.354 readMap("+" + name,
2.355 - _reader_bits::writeComposeMap(map, forwardMap(graph)), reader);
2.356 + _reader_bits::forwardComposeMap(graph, map), reader);
2.357 readMap("-" + name,
2.358 - _reader_bits::writeComposeMap(map, backwardMap(graph)), reader);
2.359 + _reader_bits::backwardComposeMap(graph, map), reader);
2.360 return *this;
2.361 }
2.362
2.363 @@ -1336,7 +1408,7 @@
2.364 typedef std::map<std::string, ReaderBase<UndirEdge>*> MapReaders;
2.365 MapReaders readers;
2.366
2.367 - typename SmartReference<Graph>::Type graph;
2.368 + Graph& graph;
2.369 std::string id;
2.370 SkipReader<UndirEdge, DefaultSkipper> skipper;
2.371
3.1 --- a/lemon/lemon_writer.h Wed Oct 05 13:17:42 2005 +0000
3.2 +++ b/lemon/lemon_writer.h Wed Oct 05 13:18:51 2005 +0000
3.3 @@ -35,6 +35,7 @@
3.4 #include <lemon/bits/item_writer.h>
3.5 #include <lemon/utility.h>
3.6 #include <lemon/maps.h>
3.7 +#include <lemon/xy.h>
3.8
3.9 #include <lemon/concept_check.h>
3.10 #include <lemon/concept/maps.h>
3.11 @@ -84,6 +85,85 @@
3.12
3.13 };
3.14
3.15 + template <typename Map>
3.16 + struct Ref { typedef const Map& Type; };
3.17 +
3.18 + template <typename Graph, typename Map>
3.19 + class ForwardComposeMap {
3.20 + public:
3.21 + typedef typename Graph::UndirEdge Key;
3.22 + typedef typename Map::Value Value;
3.23 +
3.24 + ForwardComposeMap(const Graph& _graph, const Map& _map)
3.25 + : graph(_graph), map(_map) {}
3.26 +
3.27 + Value operator[](const Key& key) {
3.28 + return map[graph.direct(key, false)];
3.29 + }
3.30 +
3.31 + private:
3.32 + typename Ref<Map>::Type map;
3.33 + const Graph& graph;
3.34 + };
3.35 +
3.36 + template <typename Graph, typename Map>
3.37 + ForwardComposeMap<Graph, Map>
3.38 + forwardComposeMap(const Graph& graph, const Map& map) {
3.39 + return ForwardComposeMap<Graph, Map>(graph, map);
3.40 + }
3.41 +
3.42 + template <typename Graph, typename Map>
3.43 + class BackwardComposeMap {
3.44 + public:
3.45 + typedef typename Graph::UndirEdge Key;
3.46 + typedef typename Map::Value Value;
3.47 +
3.48 + BackwardComposeMap(const Graph& _graph, const Map& _map)
3.49 + : graph(_graph), map(_map) {}
3.50 +
3.51 + Value operator[](const Key& key) {
3.52 + return map[graph.direct(key, false)];
3.53 + }
3.54 +
3.55 + private:
3.56 + typename Ref<Map>::Type map;
3.57 + const Graph& graph;
3.58 + };
3.59 +
3.60 + template <typename Graph, typename Map>
3.61 + BackwardComposeMap<Graph, Map>
3.62 + backwardComposeMap(const Graph& graph, const Map& map) {
3.63 + return BackwardComposeMap<Graph, Map>(graph, map);
3.64 + }
3.65 +
3.66 + template <typename Graph, typename Map>
3.67 + struct Ref<ForwardComposeMap<Graph, Map> > {
3.68 + typedef ForwardComposeMap<Graph, Map> Type;
3.69 + };
3.70 +
3.71 + template <typename Graph, typename Map>
3.72 + struct Ref<BackwardComposeMap<Graph, Map> > {
3.73 + typedef BackwardComposeMap<Graph, Map> Type;
3.74 + };
3.75 +
3.76 + template <typename Map>
3.77 + struct Ref<XMap<Map> > {
3.78 + typedef XMap<Map> Type;
3.79 + };
3.80 + template <typename Map>
3.81 + struct Ref<ConstXMap<Map> > {
3.82 + typedef ConstXMap<Map> Type;
3.83 + };
3.84 +
3.85 + template <typename Map>
3.86 + struct Ref<YMap<Map> > {
3.87 + typedef YMap<Map> Type;
3.88 + };
3.89 + template <typename Map>
3.90 + struct Ref<ConstYMap<Map> > {
3.91 + typedef ConstYMap<Map> Type;
3.92 + };
3.93 +
3.94 }
3.95
3.96 /// \ingroup io_group
3.97 @@ -234,7 +314,7 @@
3.98 typedef typename Writer::Value Value;
3.99 typedef _Item Item;
3.100
3.101 - typename SmartConstReference<Map>::Type map;
3.102 + typename _writer_bits::Ref<Map>::Type map;
3.103 Writer writer;
3.104
3.105 MapWriter(const Map& _map, const Writer& _writer)
3.106 @@ -453,7 +533,7 @@
3.107 WriterBase<Node>* idMap;
3.108 bool forceIdMap;
3.109
3.110 - typename SmartConstReference<Graph>::Type graph;
3.111 + const Graph& graph;
3.112 std::string id;
3.113
3.114 };
3.115 @@ -627,7 +707,7 @@
3.116 WriterBase<Edge>* idMap;
3.117 bool forceIdMap;
3.118
3.119 - typename SmartConstReference<Graph>::Type graph;
3.120 + const Graph& graph;
3.121 std::string id;
3.122
3.123 std::auto_ptr<IdWriterBase<Node> > nodeIdWriter;
3.124 @@ -746,8 +826,10 @@
3.125 const Writer& writer = Writer()) {
3.126 checkConcept<concept::ReadMap<Edge, typename Map::Value>, Map>();
3.127 checkConcept<_writer_bits::ItemWriter<typename Map::Value>, Writer>();
3.128 - writeUndirEdge("+" + name, composeMap(forwardMap(graph), map), writer);
3.129 - writeUndirEdge("-" + name, composeMap(backwardMap(graph), map), writer);
3.130 + writeUndirEdge("+" + name,
3.131 + _writer_bits::forwardComposeMap(graph, map), writer);
3.132 + writeUndirEdge("-" + name,
3.133 + _writer_bits::backwardComposeMap(graph, map), writer);
3.134 return *this;
3.135 }
3.136
3.137 @@ -853,7 +935,7 @@
3.138 WriterBase<UndirEdge>* idMap;
3.139 bool forceIdMap;
3.140
3.141 - typename SmartConstReference<Graph>::Type graph;
3.142 + const Graph& graph;
3.143 std::string id;
3.144
3.145 std::auto_ptr<IdWriterBase<Node> > nodeIdWriter;
4.1 --- a/lemon/maps.h Wed Oct 05 13:17:42 2005 +0000
4.2 +++ b/lemon/maps.h Wed Oct 05 13:18:51 2005 +0000
4.3 @@ -38,11 +38,9 @@
4.4
4.5 /// Base class of maps.
4.6 /// It provides the necessary <tt>typedef</tt>s required by the map concept.
4.7 - template<typename K, typename T, typename _NeedCopy = False>
4.8 + template<typename K, typename T>
4.9 class MapBase {
4.10 public:
4.11 - /// \e
4.12 - typedef _NeedCopy NeedCopy;
4.13 ///\e
4.14 typedef K Key;
4.15 ///\e
4.16 @@ -54,10 +52,10 @@
4.17 /// If you have to provide a map only for its type definitions,
4.18 /// or if you have to provide a writable map, but
4.19 /// data written to it will sent to <tt>/dev/null</tt>...
4.20 - template<typename K, typename T, typename NC = False>
4.21 - class NullMap : public MapBase<K, T, NC> {
4.22 + template<typename K, typename T>
4.23 + class NullMap : public MapBase<K, T> {
4.24 public:
4.25 - typedef MapBase<K, T, NC> Parent;
4.26 + typedef MapBase<K, T> Parent;
4.27 typedef typename Parent::Key Key;
4.28 typedef typename Parent::Value Value;
4.29
4.30 @@ -68,8 +66,8 @@
4.31 };
4.32
4.33 template <typename K, typename V>
4.34 - NullMap<K, V, True> nullMap() {
4.35 - return NullMap<K, V, True>();
4.36 + NullMap<K, V> nullMap() {
4.37 + return NullMap<K, V>();
4.38 }
4.39
4.40
4.41 @@ -78,13 +76,13 @@
4.42 /// This is a readable map which assigns a specified value to each key.
4.43 /// In other aspects it is equivalent to the \ref NullMap.
4.44 /// \todo set could be used to set the value.
4.45 - template<typename K, typename T, typename NC = False>
4.46 - class ConstMap : public MapBase<K, T, NC> {
4.47 + template<typename K, typename T>
4.48 + class ConstMap : public MapBase<K, T> {
4.49 private:
4.50 T v;
4.51 public:
4.52
4.53 - typedef MapBase<K, T, NC> Parent;
4.54 + typedef MapBase<K, T> Parent;
4.55 typedef typename Parent::Key Key;
4.56 typedef typename Parent::Value Value;
4.57
4.58 @@ -116,8 +114,8 @@
4.59 ///This function just returns a \ref ConstMap class.
4.60 ///\relates ConstMap
4.61 template<typename K, typename V>
4.62 - inline ConstMap<K, V, True> constMap(const V &v) {
4.63 - return ConstMap<K, V, True>(v);
4.64 + inline ConstMap<K, V> constMap(const V &v) {
4.65 + return ConstMap<K, V>(v);
4.66 }
4.67
4.68
4.69 @@ -126,10 +124,10 @@
4.70 struct Const { };
4.71
4.72 //\todo to document later
4.73 - template<typename K, typename V, V v, typename NC>
4.74 - class ConstMap<K, Const<V, v>, NC > : public MapBase<K, V, NC> {
4.75 + template<typename K, typename V, V v>
4.76 + class ConstMap<K, Const<V, v> > : public MapBase<K, V> {
4.77 public:
4.78 - typedef MapBase<K, V, False> Parent;
4.79 + typedef MapBase<K, V> Parent;
4.80 typedef typename Parent::Key Key;
4.81 typedef typename Parent::Value Value;
4.82
4.83 @@ -143,8 +141,8 @@
4.84 ///This function just returns a \ref ConstMap class.
4.85 ///\relates ConstMap
4.86 template<typename K, typename V, V v>
4.87 - inline ConstMap<K, Const<V, v>, True> constMap() {
4.88 - return ConstMap<K, Const<V, v>, True>();
4.89 + inline ConstMap<K, Const<V, v> > constMap() {
4.90 + return ConstMap<K, Const<V, v> >();
4.91 }
4.92
4.93 /// \c std::map wrapper
4.94 @@ -225,10 +223,10 @@
4.95 ///
4.96 /// This mapping gives back the given key as value without any
4.97 /// modification.
4.98 - template <typename T, typename NC = False>
4.99 - class IdentityMap : public MapBase<T, T, NC> {
4.100 + template <typename T>
4.101 + class IdentityMap : public MapBase<T, T> {
4.102 public:
4.103 - typedef MapBase<T, T, NC> Parent;
4.104 + typedef MapBase<T, T> Parent;
4.105 typedef typename Parent::Key Key;
4.106 typedef typename Parent::Value Value;
4.107
4.108 @@ -242,8 +240,8 @@
4.109 ///This function just returns an \ref IdentityMap class.
4.110 ///\relates IdentityMap
4.111 template<typename T>
4.112 - inline IdentityMap<T, True> identityMap() {
4.113 - return IdentityMap<T, True>();
4.114 + inline IdentityMap<T> identityMap() {
4.115 + return IdentityMap<T>();
4.116 }
4.117
4.118
4.119 @@ -252,11 +250,11 @@
4.120 ///This \ref concept::ReadMap "read only map"
4.121 ///converts the \c Value of a maps to type \c T.
4.122 ///Its \c Key is inherited from \c M.
4.123 - template <typename M, typename T, typename NC = False>
4.124 - class ConvertMap : public MapBase<typename M::Key, T, NC> {
4.125 - typename SmartConstReference<M>::Type m;
4.126 + template <typename M, typename T>
4.127 + class ConvertMap : public MapBase<typename M::Key, T> {
4.128 + const M& m;
4.129 public:
4.130 - typedef MapBase<typename M::Key, T, NC> Parent;
4.131 + typedef MapBase<typename M::Key, T> Parent;
4.132 typedef typename Parent::Key Key;
4.133 typedef typename Parent::Value Value;
4.134
4.135 @@ -280,8 +278,8 @@
4.136 ///\relates ConvertMap
4.137 ///\todo The order of the template parameters are changed.
4.138 template<typename T, typename M>
4.139 - inline ConvertMap<M, T, True> convertMap(const M &m) {
4.140 - return ConvertMap<M, T, True>(m);
4.141 + inline ConvertMap<M, T> convertMap(const M &m) {
4.142 + return ConvertMap<M, T>(m);
4.143 }
4.144
4.145 ///Sum of two maps
4.146 @@ -290,13 +288,13 @@
4.147 ///given maps. Its \c Key and \c Value will be inherited from \c M1.
4.148 ///The \c Key and \c Value of M2 must be convertible to those of \c M1.
4.149
4.150 - template<typename M1, typename M2, typename NC = False>
4.151 - class AddMap : public MapBase<typename M1::Key, typename M1::Value, NC> {
4.152 - typename SmartConstReference<M1>::Type m1;
4.153 - typename SmartConstReference<M2>::Type m2;
4.154 + template<typename M1, typename M2>
4.155 + class AddMap : public MapBase<typename M1::Key, typename M1::Value> {
4.156 + const M1& m1;
4.157 + const M2& m2;
4.158
4.159 public:
4.160 - typedef MapBase<typename M1::Key, typename M1::Value, NC> Parent;
4.161 + typedef MapBase<typename M1::Key, typename M1::Value> Parent;
4.162 typedef typename Parent::Key Key;
4.163 typedef typename Parent::Value Value;
4.164
4.165 @@ -313,8 +311,8 @@
4.166 ///\relates AddMap
4.167 ///\todo Wrong scope in Doxygen when \c \\relates is used
4.168 template<typename M1, typename M2>
4.169 - inline AddMap<M1, M2, True> addMap(const M1 &m1,const M2 &m2) {
4.170 - return AddMap<M1, M2, True>(m1,m2);
4.171 + inline AddMap<M1, M2> addMap(const M1 &m1,const M2 &m2) {
4.172 + return AddMap<M1, M2>(m1,m2);
4.173 }
4.174
4.175 ///Shift a map with a constant.
4.176 @@ -332,12 +330,12 @@
4.177 /// ConstMap<X::Key, X::Value> c_tmp(v);
4.178 /// AddMap<X, ConstMap<X::Key, X::Value> > sh(x,v);
4.179 ///\endcode
4.180 - template<typename M, typename C = typename M::Value, typename NC = False>
4.181 - class ShiftMap : public MapBase<typename M::Key, typename M::Value, NC> {
4.182 - typename SmartConstReference<M>::Type m;
4.183 + template<typename M, typename C = typename M::Value>
4.184 + class ShiftMap : public MapBase<typename M::Key, typename M::Value> {
4.185 + const M& m;
4.186 C v;
4.187 public:
4.188 - typedef MapBase<typename M::Key, typename M::Value, NC> Parent;
4.189 + typedef MapBase<typename M::Key, typename M::Value> Parent;
4.190 typedef typename Parent::Key Key;
4.191 typedef typename Parent::Value Value;
4.192
4.193 @@ -356,8 +354,8 @@
4.194 ///\relates ShiftMap
4.195 ///\todo A better name is required.
4.196 template<typename M, typename C>
4.197 - inline ShiftMap<M, C, True> shiftMap(const M &m,const C &v) {
4.198 - return ShiftMap<M, C, True>(m,v);
4.199 + inline ShiftMap<M, C> shiftMap(const M &m,const C &v) {
4.200 + return ShiftMap<M, C>(m,v);
4.201 }
4.202
4.203 ///Difference of two maps
4.204 @@ -367,12 +365,12 @@
4.205 ///given maps. Its \c Key and \c Value will be inherited from \c M1.
4.206 ///The \c Key and \c Value of \c M2 must be convertible to those of \c M1.
4.207
4.208 - template<typename M1, typename M2, typename NC = False>
4.209 - class SubMap : public MapBase<typename M1::Key, typename M1::Value, NC> {
4.210 - typename SmartConstReference<M1>::Type m1;
4.211 - typename SmartConstReference<M2>::Type m2;
4.212 + template<typename M1, typename M2>
4.213 + class SubMap : public MapBase<typename M1::Key, typename M1::Value> {
4.214 + const M1& m1;
4.215 + const M2& m2;
4.216 public:
4.217 - typedef MapBase<typename M1::Key, typename M1::Value, NC> Parent;
4.218 + typedef MapBase<typename M1::Key, typename M1::Value> Parent;
4.219 typedef typename Parent::Key Key;
4.220 typedef typename Parent::Value Value;
4.221
4.222 @@ -387,8 +385,8 @@
4.223 ///
4.224 ///\relates SubMap
4.225 template<typename M1, typename M2>
4.226 - inline SubMap<M1, M2, True> subMap(const M1 &m1, const M2 &m2) {
4.227 - return SubMap<M1, M2, True>(m1, m2);
4.228 + inline SubMap<M1, M2> subMap(const M1 &m1, const M2 &m2) {
4.229 + return SubMap<M1, M2>(m1, m2);
4.230 }
4.231
4.232 ///Product of two maps
4.233 @@ -399,12 +397,12 @@
4.234 ///maps. Its \c Key and \c Value will be inherited from \c M1.
4.235 ///The \c Key and \c Value of \c M2 must be convertible to those of \c M1.
4.236
4.237 - template<typename M1, typename M2, typename NC = False>
4.238 - class MulMap : public MapBase<typename M1::Key, typename M1::Value, NC> {
4.239 - typename SmartConstReference<M1>::Type m1;
4.240 - typename SmartConstReference<M2>::Type m2;
4.241 + template<typename M1, typename M2>
4.242 + class MulMap : public MapBase<typename M1::Key, typename M1::Value> {
4.243 + const M1& m1;
4.244 + const M2& m2;
4.245 public:
4.246 - typedef MapBase<typename M1::Key, typename M1::Value, NC> Parent;
4.247 + typedef MapBase<typename M1::Key, typename M1::Value> Parent;
4.248 typedef typename Parent::Key Key;
4.249 typedef typename Parent::Value Value;
4.250
4.251 @@ -418,8 +416,8 @@
4.252 ///This function just returns a \ref MulMap class.
4.253 ///\relates MulMap
4.254 template<typename M1, typename M2>
4.255 - inline MulMap<M1, M2, True> mulMap(const M1 &m1,const M2 &m2) {
4.256 - return MulMap<M1, M2, True>(m1,m2);
4.257 + inline MulMap<M1, M2> mulMap(const M1 &m1,const M2 &m2) {
4.258 + return MulMap<M1, M2>(m1,m2);
4.259 }
4.260
4.261 ///Scales a maps with a constant.
4.262 @@ -437,12 +435,12 @@
4.263 /// ConstMap<X::Key, X::Value> c_tmp(v);
4.264 /// MulMap<X, ConstMap<X::Key, X::Value> > sc(x,v);
4.265 ///\endcode
4.266 - template<typename M, typename C = typename M::Value, typename NC = False>
4.267 - class ScaleMap : public MapBase<typename M::Key, typename M::Value, NC> {
4.268 - typename SmartConstReference<M>::Type m;
4.269 + template<typename M, typename C = typename M::Value>
4.270 + class ScaleMap : public MapBase<typename M::Key, typename M::Value> {
4.271 + const M& m;
4.272 C v;
4.273 public:
4.274 - typedef MapBase<typename M::Key, typename M::Value, NC> Parent;
4.275 + typedef MapBase<typename M::Key, typename M::Value> Parent;
4.276 typedef typename Parent::Key Key;
4.277 typedef typename Parent::Value Value;
4.278
4.279 @@ -461,8 +459,8 @@
4.280 ///\relates ScaleMap
4.281 ///\todo A better name is required.
4.282 template<typename M, typename C>
4.283 - inline ScaleMap<M, C, True> scaleMap(const M &m,const C &v) {
4.284 - return ScaleMap<M, C, True>(m,v);
4.285 + inline ScaleMap<M, C> scaleMap(const M &m,const C &v) {
4.286 + return ScaleMap<M, C>(m,v);
4.287 }
4.288
4.289 ///Quotient of two maps
4.290 @@ -472,12 +470,12 @@
4.291 ///given maps. Its \c Key and \c Value will be inherited from \c M1.
4.292 ///The \c Key and \c Value of \c M2 must be convertible to those of \c M1.
4.293
4.294 - template<typename M1, typename M2, typename NC = False>
4.295 - class DivMap : public MapBase<typename M1::Key, typename M1::Value, NC> {
4.296 - typename SmartConstReference<M1>::Type m1;
4.297 - typename SmartConstReference<M2>::Type m2;
4.298 + template<typename M1, typename M2>
4.299 + class DivMap : public MapBase<typename M1::Key, typename M1::Value> {
4.300 + const M1& m1;
4.301 + const M2& m2;
4.302 public:
4.303 - typedef MapBase<typename M1::Key, typename M1::Value, NC> Parent;
4.304 + typedef MapBase<typename M1::Key, typename M1::Value> Parent;
4.305 typedef typename Parent::Key Key;
4.306 typedef typename Parent::Value Value;
4.307
4.308 @@ -491,8 +489,8 @@
4.309 ///This function just returns a \ref DivMap class.
4.310 ///\relates DivMap
4.311 template<typename M1, typename M2>
4.312 - inline DivMap<M1, M2, True> divMap(const M1 &m1,const M2 &m2) {
4.313 - return DivMap<M1, M2, True>(m1,m2);
4.314 + inline DivMap<M1, M2> divMap(const M1 &m1,const M2 &m2) {
4.315 + return DivMap<M1, M2>(m1,m2);
4.316 }
4.317
4.318 ///Composition of two maps
4.319 @@ -512,12 +510,12 @@
4.320 ///The \c M2::Value must be convertible to \c M1::Key.
4.321 ///\todo Check the requirements.
4.322
4.323 - template <typename M1, typename M2, typename NC = False>
4.324 - class ComposeMap : public MapBase<typename M2::Key, typename M1::Value, NC> {
4.325 - typename SmartConstReference<M1>::Type m1;
4.326 - typename SmartConstReference<M2>::Type m2;
4.327 + template <typename M1, typename M2>
4.328 + class ComposeMap : public MapBase<typename M2::Key, typename M1::Value> {
4.329 + const M1& m1;
4.330 + const M2& m2;
4.331 public:
4.332 - typedef MapBase<typename M2::Key, typename M1::Value, NC> Parent;
4.333 + typedef MapBase<typename M2::Key, typename M1::Value> Parent;
4.334 typedef typename Parent::Key Key;
4.335 typedef typename Parent::Value Value;
4.336
4.337 @@ -531,8 +529,8 @@
4.338 ///
4.339 ///\relates ComposeMap
4.340 template <typename M1, typename M2>
4.341 - inline ComposeMap<M1, M2, True> composeMap(const M1 &m1,const M2 &m2) {
4.342 - return ComposeMap<M1, M2, True>(m1,m2);
4.343 + inline ComposeMap<M1, M2> composeMap(const M1 &m1,const M2 &m2) {
4.344 + return ComposeMap<M1, M2>(m1,m2);
4.345 }
4.346
4.347 ///Combines of two maps using an STL (binary) functor.
4.348 @@ -561,12 +559,12 @@
4.349 template<typename M1, typename M2, typename F,
4.350 typename V = typename F::result_type,
4.351 typename NC = False>
4.352 - class CombineMap : public MapBase<typename M1::Key, V, NC> {
4.353 - typename SmartConstReference<M1>::Type m1;
4.354 - typename SmartConstReference<M2>::Type m2;
4.355 + class CombineMap : public MapBase<typename M1::Key, V> {
4.356 + const M1& m1;
4.357 + const M2& m2;
4.358 F f;
4.359 public:
4.360 - typedef MapBase<typename M1::Key, V, NC> Parent;
4.361 + typedef MapBase<typename M1::Key, V> Parent;
4.362 typedef typename Parent::Key Key;
4.363 typedef typename Parent::Value Value;
4.364
4.365 @@ -593,19 +591,19 @@
4.366 ///
4.367 ///\relates CombineMap
4.368 template<typename M1, typename M2, typename F, typename V>
4.369 - inline CombineMap<M1, M2, F, V, True>
4.370 + inline CombineMap<M1, M2, F, V>
4.371 combineMap(const M1& m1,const M2& m2, const F& f) {
4.372 - return CombineMap<M1, M2, F, V, True>(m1,m2,f);
4.373 + return CombineMap<M1, M2, F, V>(m1,m2,f);
4.374 }
4.375
4.376 template<typename M1, typename M2, typename F>
4.377 - inline CombineMap<M1, M2, F, typename F::result_type, True>
4.378 + inline CombineMap<M1, M2, F, typename F::result_type>
4.379 combineMap(const M1& m1, const M2& m2, const F& f) {
4.380 return combineMap<M1, M2, F, typename F::result_type>(m1,m2,f);
4.381 }
4.382
4.383 template<typename M1, typename M2, typename K1, typename K2, typename V>
4.384 - inline CombineMap<M1, M2, V (*)(K1, K2), V, True>
4.385 + inline CombineMap<M1, M2, V (*)(K1, K2), V>
4.386 combineMap(const M1 &m1, const M2 &m2, V (*f)(K1, K2)) {
4.387 return combineMap<M1, M2, V (*)(K1, K2), V>(m1,m2,f);
4.388 }
4.389 @@ -618,11 +616,11 @@
4.390 ///given map. Its \c Key and \c Value will be inherited from \c M.
4.391 ///The unary \c - operator must be defined for \c Value, of course.
4.392
4.393 - template<typename M, typename NC = False>
4.394 - class NegMap : public MapBase<typename M::Key, typename M::Value, NC> {
4.395 - typename SmartConstReference<M>::Type m;
4.396 + template<typename M>
4.397 + class NegMap : public MapBase<typename M::Key, typename M::Value> {
4.398 + const M& m;
4.399 public:
4.400 - typedef MapBase<typename M::Key, typename M::Value, NC> Parent;
4.401 + typedef MapBase<typename M::Key, typename M::Value> Parent;
4.402 typedef typename Parent::Key Key;
4.403 typedef typename Parent::Value Value;
4.404
4.405 @@ -636,8 +634,8 @@
4.406 ///This function just returns a \ref NegMap class.
4.407 ///\relates NegMap
4.408 template <typename M>
4.409 - inline NegMap<M, True> negMap(const M &m) {
4.410 - return NegMap<M, True>(m);
4.411 + inline NegMap<M> negMap(const M &m) {
4.412 + return NegMap<M>(m);
4.413 }
4.414
4.415
4.416 @@ -664,11 +662,11 @@
4.417 ///\endcode
4.418
4.419
4.420 - template<typename M, typename NC = False>
4.421 - class AbsMap : public MapBase<typename M::Key, typename M::Value, NC> {
4.422 - typename SmartConstReference<M>::Type m;
4.423 + template<typename M>
4.424 + class AbsMap : public MapBase<typename M::Key, typename M::Value> {
4.425 + const M& m;
4.426 public:
4.427 - typedef MapBase<typename M::Key, typename M::Value, NC> Parent;
4.428 + typedef MapBase<typename M::Key, typename M::Value> Parent;
4.429 typedef typename Parent::Key Key;
4.430 typedef typename Parent::Value Value;
4.431
4.432 @@ -686,8 +684,8 @@
4.433 ///This function just returns a \ref AbsMap class.
4.434 ///\relates AbsMap
4.435 template<typename M>
4.436 - inline AbsMap<M, True> absMap(const M &m) {
4.437 - return AbsMap<M, True>(m);
4.438 + inline AbsMap<M> absMap(const M &m) {
4.439 + return AbsMap<M>(m);
4.440 }
4.441
4.442 ///Converts an STL style functor to a map
4.443 @@ -707,10 +705,10 @@
4.444 typename K = typename F::argument_type,
4.445 typename V = typename F::result_type,
4.446 typename NC = False>
4.447 - class FunctorMap : public MapBase<K, V, NC> {
4.448 + class FunctorMap : public MapBase<K, V> {
4.449 F f;
4.450 public:
4.451 - typedef MapBase<K, V, NC> Parent;
4.452 + typedef MapBase<K, V> Parent;
4.453 typedef typename Parent::Key Key;
4.454 typedef typename Parent::Value Value;
4.455
4.456 @@ -727,20 +725,20 @@
4.457 ///The third template parameter isn't necessary to be given.
4.458 ///\relates FunctorMap
4.459 template<typename K, typename V, typename F> inline
4.460 - FunctorMap<F, K, V, True> functorMap(const F &f) {
4.461 - return FunctorMap<F, K, V, True>(f);
4.462 + FunctorMap<F, K, V> functorMap(const F &f) {
4.463 + return FunctorMap<F, K, V>(f);
4.464 }
4.465
4.466 template <typename F> inline
4.467 - FunctorMap<F, typename F::argument_type, typename F::result_type, True>
4.468 + FunctorMap<F, typename F::argument_type, typename F::result_type>
4.469 functorMap(const F &f) {
4.470 return FunctorMap<F, typename F::argument_type,
4.471 - typename F::result_type, True>(f);
4.472 + typename F::result_type>(f);
4.473 }
4.474
4.475 template <typename K, typename V> inline
4.476 - FunctorMap<V (*)(K), K, V, True> functorMap(V (*f)(K)) {
4.477 - return FunctorMap<V (*)(K), K, V, True>(f);
4.478 + FunctorMap<V (*)(K), K, V> functorMap(V (*f)(K)) {
4.479 + return FunctorMap<V (*)(K), K, V>(f);
4.480 }
4.481
4.482
4.483 @@ -753,11 +751,11 @@
4.484 ///a ususal \ref concept::ReadMap "readable map",
4.485 ///i.e. <tt>operator[]</tt> and the \c Key and \c Value typedefs also exist.
4.486
4.487 - template <typename M, typename NC = False>
4.488 - class MapFunctor : public MapBase<typename M::Key, typename M::Value, NC> {
4.489 - typename SmartConstReference<M>::Type m;
4.490 + template <typename M>
4.491 + class MapFunctor : public MapBase<typename M::Key, typename M::Value> {
4.492 + const M& m;
4.493 public:
4.494 - typedef MapBase<typename M::Key, typename M::Value, NC> Parent;
4.495 + typedef MapBase<typename M::Key, typename M::Value> Parent;
4.496 typedef typename Parent::Key Key;
4.497 typedef typename Parent::Value Value;
4.498
4.499 @@ -779,8 +777,8 @@
4.500 ///This function just returns a \ref MapFunctor class.
4.501 ///\relates MapFunctor
4.502 template<typename M>
4.503 - inline MapFunctor<M, True> mapFunctor(const M &m) {
4.504 - return MapFunctor<M, True>(m);
4.505 + inline MapFunctor<M> mapFunctor(const M &m) {
4.506 + return MapFunctor<M>(m);
4.507 }
4.508
4.509
4.510 @@ -795,12 +793,12 @@
4.511 ///The \c Key and \c Value will be inherited from \c M1.
4.512 ///The \c Key and \c Value of M2 must be convertible from those of \c M1.
4.513
4.514 - template<typename M1, typename M2, typename NC = False>
4.515 - class ForkMap : public MapBase<typename M1::Key, typename M1::Value, NC> {
4.516 - typename SmartConstReference<M1>::Type m1;
4.517 - typename SmartConstReference<M2>::Type m2;
4.518 + template<typename M1, typename M2>
4.519 + class ForkMap : public MapBase<typename M1::Key, typename M1::Value> {
4.520 + const M1& m1;
4.521 + const M2& m2;
4.522 public:
4.523 - typedef MapBase<typename M1::Key, typename M1::Value, NC> Parent;
4.524 + typedef MapBase<typename M1::Key, typename M1::Value> Parent;
4.525 typedef typename Parent::Key Key;
4.526 typedef typename Parent::Value Value;
4.527
4.528 @@ -818,8 +816,8 @@
4.529 ///\relates ForkMap
4.530 ///\todo Wrong scope in Doxygen when \c \\relates is used
4.531 template <typename M1, typename M2>
4.532 - inline ForkMap<M1, M2, True> forkMap(const M1 &m1,const M2 &m2) {
4.533 - return ForkMap<M1, M2, True>(m1,m2);
4.534 + inline ForkMap<M1, M2> forkMap(const M1 &m1,const M2 &m2) {
4.535 + return ForkMap<M1, M2>(m1,m2);
4.536 }
4.537
4.538
4.539 @@ -834,11 +832,11 @@
4.540 ///given map. Its \c Key and will be inherited from \c M,
4.541 ///its Value is <tt>bool</tt>.
4.542
4.543 - template <typename M, typename NC = False>
4.544 - class NotMap : public MapBase<typename M::Key, bool, NC> {
4.545 - typename SmartConstReference<M>::Type m;
4.546 + template <typename M>
4.547 + class NotMap : public MapBase<typename M::Key, bool> {
4.548 + const M& m;
4.549 public:
4.550 - typedef MapBase<typename M::Key, bool, NC> Parent;
4.551 + typedef MapBase<typename M::Key, bool> Parent;
4.552 typedef typename Parent::Key Key;
4.553 typedef typename Parent::Value Value;
4.554
4.555 @@ -852,8 +850,8 @@
4.556 ///This function just returns a \ref NotMap class.
4.557 ///\relates NotMap
4.558 template <typename M>
4.559 - inline NotMap<M, True> notMap(const M &m) {
4.560 - return NotMap<M, True>(m);
4.561 + inline NotMap<M> notMap(const M &m) {
4.562 + return NotMap<M>(m);
4.563 }
4.564
4.565 /// @}
5.1 --- a/lemon/utility.h Wed Oct 05 13:17:42 2005 +0000
5.2 +++ b/lemon/utility.h Wed Oct 05 13:18:51 2005 +0000
5.3 @@ -139,47 +139,6 @@
5.4 template <class Cond, class T>
5.5 struct lazy_disable_if : public lazy_disable_if_c<Cond::value, T> {};
5.6
5.7 - // smart referencing
5.8 -
5.9 - template <typename _Type, typename Enable = void>
5.10 - struct SmartReference {
5.11 - typedef _Type& Type;
5.12 - };
5.13 -
5.14 - template <typename _Type>
5.15 - struct SmartReference<
5.16 - _Type,
5.17 - typename enable_if<typename _Type::NeedCopy, void>::type
5.18 - > {
5.19 - typedef _Type Type;
5.20 - };
5.21 -
5.22 - template <typename _Type, typename Enable = void>
5.23 - struct SmartConstReference {
5.24 - typedef const _Type& Type;
5.25 - };
5.26 -
5.27 - template <typename _Type>
5.28 - struct SmartConstReference<
5.29 - _Type,
5.30 - typename enable_if<typename _Type::NeedCopy, void>::type
5.31 - > {
5.32 - typedef const _Type Type;
5.33 - };
5.34 -
5.35 - template <typename _Type, typename Enable = void>
5.36 - struct SmartParameter {
5.37 - typedef _Type& Type;
5.38 - };
5.39 -
5.40 - template <typename _Type>
5.41 - struct SmartParameter<
5.42 - _Type,
5.43 - typename enable_if<typename _Type::NeedCopy, void>::type
5.44 - > {
5.45 - typedef const _Type& Type;
5.46 - };
5.47 -
5.48 } // namespace lemon
5.49
5.50 #endif