# HG changeset patch # User deba # Date 1128518331 0 # Node ID 3f63d9db307ba5c1d7b9552515f96bd69cfe74f5 # Parent 467d7927a901586de48fa9d1f11e81d390d9b193 Removing smart references diff -r 467d7927a901 -r 3f63d9db307b lemon/graph_reader.h --- a/lemon/graph_reader.h Wed Oct 05 13:17:42 2005 +0000 +++ b/lemon/graph_reader.h Wed Oct 05 13:18:51 2005 +0000 @@ -122,8 +122,7 @@ /// /// Construct a new GraphReader. It reads into the given graph /// and it uses the given reader as the default skipper. - GraphReader(std::istream& _is, - typename SmartParameter::Type _graph, + GraphReader(std::istream& _is, Graph& _graph, const DefaultSkipper& _skipper = DefaultSkipper()) : reader(new LemonReader(_is)), own_reader(true), skipper(_skipper), nodeset_reader(*reader, _graph, std::string(), skipper), @@ -137,8 +136,7 @@ /// /// Construct a new GraphReader. It reads into the given graph /// and it uses the given reader as the default skipper. - GraphReader(const std::string& _filename, - typename SmartParameter::Type _graph, + GraphReader(const std::string& _filename, Graph& _graph, const DefaultSkipper& _skipper = DefaultSkipper()) : reader(new LemonReader(_filename)), own_reader(true), skipper(_skipper), @@ -153,8 +151,7 @@ /// /// Construct a new GraphReader. It reads into the given graph /// and it uses the given reader as the default skipper. - GraphReader(LemonReader& _reader, - typename SmartParameter::Type _graph, + GraphReader(LemonReader& _reader, Graph& _graph, const DefaultSkipper& _skipper = DefaultSkipper()) : reader(_reader), own_reader(false), skipper(_skipper), nodeset_reader(*reader, _graph, std::string(), skipper), diff -r 467d7927a901 -r 3f63d9db307b lemon/lemon_reader.h --- a/lemon/lemon_reader.h Wed Oct 05 13:17:42 2005 +0000 +++ b/lemon/lemon_reader.h Wed Oct 05 13:18:51 2005 +0000 @@ -36,6 +36,8 @@ #include #include +#include + #include #include @@ -94,38 +96,108 @@ } }; - template - class WriteComposeMap { + template + struct Ref { typedef Map& Type; }; + template + struct Arg { typedef Map& Type; }; + + template + class ForwardComposeMap { public: - typedef True NeedCopy; + typedef typename Graph::UndirEdge Key; + typedef typename Map::Value Value; + + ForwardComposeMap(const Graph& _graph, typename Arg::Type _map) + : graph(_graph), map(_map) {} - typedef typename M2::Key Key; - typedef typename M1::Value Value; - - WriteComposeMap(typename SmartParameter::Type _m1, const M2& _m2) - : m1(_m1), m2(_m2) {} - - void set(const Key& key, const Value& value) { - m1.set(m2[key], value); + void set(const Key& key, const Value& val) { + map.set(graph.direct(key, true), val); } private: - - typename SmartReference::Type m1; - typename SmartConstReference::Type m2; - + typename Ref::Type map; + const Graph& graph; }; - template - WriteComposeMap writeComposeMap(M1& m1, const M2& m2) { - return WriteComposeMap(m1, m2); + template + ForwardComposeMap + forwardComposeMap(const Graph& graph, const Map& map) { + return ForwardComposeMap(graph, map); } - template - WriteComposeMap writeComposeMap(const M1& m1, const M2& m2) { - return WriteComposeMap(m1, m2); + template + ForwardComposeMap + forwardComposeMap(const Graph& graph, Map& map) { + return ForwardComposeMap(graph, map); } - + + template + class BackwardComposeMap { + public: + typedef typename Graph::UndirEdge Key; + typedef typename Map::Value Value; + + BackwardComposeMap(const Graph& _graph, typename Arg::Type _map) + : graph(_graph), map(_map) {} + + void set(const Key& key, const Value& val) { + map.set(graph.direct(key, false), val); + } + + private: + typename Ref::Type map; + const Graph& graph; + }; + + + template + BackwardComposeMap + backwardComposeMap(const Graph& graph, const Map& map) { + return BackwardComposeMap(graph, map); + } + + template + BackwardComposeMap + backwardComposeMap(const Graph& graph, Map& map) { + return BackwardComposeMap(graph, map); + } + + template + struct Ref > { + typedef ForwardComposeMap Type; + }; + template + struct Arg > { + typedef const ForwardComposeMap& Type; + }; + + template + struct Ref > { + typedef BackwardComposeMap Type; + }; + template + struct Arg > { + typedef const BackwardComposeMap& Type; + }; + + template + struct Ref > { + typedef XMap Type; + }; + template + struct Arg > { + typedef const XMap& Type; + }; + + template + struct Ref > { + typedef YMap Type; + }; + template + struct Arg > { + typedef const YMap& Type; + }; + } /// \ingroup io_group @@ -432,11 +504,11 @@ typedef _Map Map; typedef std::map > Inverse; - typename SmartReference::Type map; + typename _reader_bits::Ref::Type map; Reader reader; Inverse inverse; - MapReaderInverter(typename SmartParameter::Type _map, + MapReaderInverter(typename _reader_bits::Arg::Type _map, const Reader& _reader) : map(_map), reader(_reader) {} @@ -526,10 +598,10 @@ typedef typename Reader::Value Value; typedef _Item Item; - typename SmartReference::Type map; + typename _reader_bits::Ref::Type map; Reader reader; - MapReader(typename SmartParameter::Type _map, + MapReader(typename _reader_bits::Arg::Type _map, const Reader& _reader) : map(_map), reader(_reader) {} @@ -659,7 +731,7 @@ /// add the readed nodes to the given Graph. The reader will read /// the section when the \c section_id and the \c _id are the same. NodeSetReader(LemonReader& _reader, - typename SmartParameter::Type _graph, + Graph& _graph, const std::string& _id = std::string(), const DefaultSkipper& _skipper = DefaultSkipper()) : Parent(_reader), graph(_graph), id(_id), skipper(_skipper) {} @@ -688,14 +760,14 @@ NodeSetReader& readNodeMap(std::string name, Map& map) { return _readMap< typename Traits::template Reader, Map, - typename SmartParameter::Type>(name, map); + typename _reader_bits::Arg::Type>(name, map); } template NodeSetReader& readNodeMap(std::string name, const Map& map) { return _readMap< typename Traits::template Reader, Map, - typename SmartParameter::Type>(name, map); + typename _reader_bits::Arg::Type>(name, map); } /// \brief Add a new node map reader command for the reader. @@ -704,14 +776,14 @@ template NodeSetReader& readNodeMap(std::string name, Map& map, const Reader& reader = Reader()) { - return _readMap::Type> + return _readMap::Type> (name, map, reader); } template NodeSetReader& readNodeMap(std::string name, const Map& map, const Reader& reader = Reader()) { - return _readMap::Type> + return _readMap::Type> (name, map, reader); } @@ -817,7 +889,7 @@ typedef std::map*> MapReaders; MapReaders readers; - typename SmartReference::Type graph; + Graph& graph; std::string id; SkipReader skipper; @@ -867,7 +939,7 @@ /// \c edgset_id are the same. template EdgeSetReader(LemonReader& _reader, - typename SmartParameter::Type _graph, + Graph& _graph, const NodeIdReader& _nodeIdReader, const std::string& _id = std::string(), const DefaultSkipper& _skipper = DefaultSkipper()) @@ -898,14 +970,14 @@ EdgeSetReader& readEdgeMap(std::string name, Map& map) { return _readMap< typename Traits::template Reader, Map, - typename SmartParameter::Type>(name, map); + typename _reader_bits::Arg::Type>(name, map); } template EdgeSetReader& readEdgeMap(std::string name, const Map& map) { return _readMap< typename Traits::template Reader, Map, - typename SmartParameter::Type>(name, map); + typename _reader_bits::Arg::Type>(name, map); } /// \brief Add a new edge map reader command for the reader. @@ -915,14 +987,14 @@ EdgeSetReader& readEdgeMap(std::string name, Map& map, const Reader& reader = Reader()) { return _readMap::Type>(name, map, reader); + typename _reader_bits::Arg::Type>(name, map, reader); } template EdgeSetReader& readEdgeMap(std::string name, const Map& map, const Reader& reader = Reader()) { return _readMap::Type>(name, map, reader); + typename _reader_bits::Arg::Type>(name, map, reader); } private: @@ -1032,7 +1104,7 @@ typedef std::map*> MapReaders; MapReaders readers; - typename SmartReference::Type graph; + Graph& graph; std::string id; SkipReader skipper; @@ -1089,7 +1161,7 @@ /// \c _id and the \c undiredgset_id are the same. template UndirEdgeSetReader(LemonReader& _reader, - typename SmartParameter::Type _graph, + Graph& _graph, const NodeIdReader& _nodeIdReader, const std::string& _id = std::string(), const DefaultSkipper& _skipper = DefaultSkipper()) @@ -1120,14 +1192,14 @@ UndirEdgeSetReader& readUndirEdgeMap(std::string name, Map& map) { return _readMap< typename Traits::template Reader, Map, - typename SmartParameter::Type>(name, map); + typename _reader_bits::Arg::Type>(name, map); } template UndirEdgeSetReader& readUndirEdgeMap(std::string name, const Map& map) { return _readMap< typename Traits::template Reader, Map, - typename SmartParameter::Type>(name, map); + typename _reader_bits::Arg::Type>(name, map); } /// \brief Add a new undirected edge map reader command for the reader. @@ -1136,14 +1208,14 @@ template UndirEdgeSetReader& readUndirEdgeMap(std::string name, Map& map, const Reader& reader = Reader()) { - return _readMap::Type> + return _readMap::Type> (name, map, reader); } template UndirEdgeSetReader& readUndirEdgeMap(std::string name, const Map& map, const Reader& reader = Reader()) { - return _readMap::Type > + return _readMap::Type > (name, map, reader); } @@ -1189,14 +1261,14 @@ UndirEdgeSetReader& readEdgeMap(std::string name, Map& map) { return _readDirMap< typename Traits::template Reader, Map, - typename SmartParameter::Type>(name, map); + typename _reader_bits::Arg::Type>(name, map); } template UndirEdgeSetReader& readEdgeMap(std::string name, const Map& map) { return _readDirMap< typename Traits::template Reader, Map, - typename SmartParameter::Type>(name, map); + typename _reader_bits::Arg::Type>(name, map); } /// \brief Add a new directed edge map reader command for the reader. @@ -1205,14 +1277,14 @@ template UndirEdgeSetReader& readEdgeMap(std::string name, Map& map, const Reader& reader = Reader()) { - return _readDirMap::Type> + return _readDirMap::Type> (name, map, reader); } template UndirEdgeSetReader& readEdgeMap(std::string name, const Map& map, const Reader& reader = Reader()) { - return _readDirMap::Type> + return _readDirMap::Type> (name, map, reader); } @@ -1224,9 +1296,9 @@ checkConcept<_reader_bits::ItemReader, Reader>(); checkConcept, Map>(); readMap("+" + name, - _reader_bits::writeComposeMap(map, forwardMap(graph)), reader); + _reader_bits::forwardComposeMap(graph, map), reader); readMap("-" + name, - _reader_bits::writeComposeMap(map, backwardMap(graph)), reader); + _reader_bits::backwardComposeMap(graph, map), reader); return *this; } @@ -1336,7 +1408,7 @@ typedef std::map*> MapReaders; MapReaders readers; - typename SmartReference::Type graph; + Graph& graph; std::string id; SkipReader skipper; diff -r 467d7927a901 -r 3f63d9db307b lemon/lemon_writer.h --- a/lemon/lemon_writer.h Wed Oct 05 13:17:42 2005 +0000 +++ b/lemon/lemon_writer.h Wed Oct 05 13:18:51 2005 +0000 @@ -35,6 +35,7 @@ #include #include #include +#include #include #include @@ -84,6 +85,85 @@ }; + template + struct Ref { typedef const Map& Type; }; + + template + class ForwardComposeMap { + public: + typedef typename Graph::UndirEdge Key; + typedef typename Map::Value Value; + + ForwardComposeMap(const Graph& _graph, const Map& _map) + : graph(_graph), map(_map) {} + + Value operator[](const Key& key) { + return map[graph.direct(key, false)]; + } + + private: + typename Ref::Type map; + const Graph& graph; + }; + + template + ForwardComposeMap + forwardComposeMap(const Graph& graph, const Map& map) { + return ForwardComposeMap(graph, map); + } + + template + class BackwardComposeMap { + public: + typedef typename Graph::UndirEdge Key; + typedef typename Map::Value Value; + + BackwardComposeMap(const Graph& _graph, const Map& _map) + : graph(_graph), map(_map) {} + + Value operator[](const Key& key) { + return map[graph.direct(key, false)]; + } + + private: + typename Ref::Type map; + const Graph& graph; + }; + + template + BackwardComposeMap + backwardComposeMap(const Graph& graph, const Map& map) { + return BackwardComposeMap(graph, map); + } + + template + struct Ref > { + typedef ForwardComposeMap Type; + }; + + template + struct Ref > { + typedef BackwardComposeMap Type; + }; + + template + struct Ref > { + typedef XMap Type; + }; + template + struct Ref > { + typedef ConstXMap Type; + }; + + template + struct Ref > { + typedef YMap Type; + }; + template + struct Ref > { + typedef ConstYMap Type; + }; + } /// \ingroup io_group @@ -234,7 +314,7 @@ typedef typename Writer::Value Value; typedef _Item Item; - typename SmartConstReference::Type map; + typename _writer_bits::Ref::Type map; Writer writer; MapWriter(const Map& _map, const Writer& _writer) @@ -453,7 +533,7 @@ WriterBase* idMap; bool forceIdMap; - typename SmartConstReference::Type graph; + const Graph& graph; std::string id; }; @@ -627,7 +707,7 @@ WriterBase* idMap; bool forceIdMap; - typename SmartConstReference::Type graph; + const Graph& graph; std::string id; std::auto_ptr > nodeIdWriter; @@ -746,8 +826,10 @@ const Writer& writer = Writer()) { checkConcept, Map>(); checkConcept<_writer_bits::ItemWriter, Writer>(); - writeUndirEdge("+" + name, composeMap(forwardMap(graph), map), writer); - writeUndirEdge("-" + name, composeMap(backwardMap(graph), map), writer); + writeUndirEdge("+" + name, + _writer_bits::forwardComposeMap(graph, map), writer); + writeUndirEdge("-" + name, + _writer_bits::backwardComposeMap(graph, map), writer); return *this; } @@ -853,7 +935,7 @@ WriterBase* idMap; bool forceIdMap; - typename SmartConstReference::Type graph; + const Graph& graph; std::string id; std::auto_ptr > nodeIdWriter; diff -r 467d7927a901 -r 3f63d9db307b lemon/maps.h --- a/lemon/maps.h Wed Oct 05 13:17:42 2005 +0000 +++ b/lemon/maps.h Wed Oct 05 13:18:51 2005 +0000 @@ -38,11 +38,9 @@ /// Base class of maps. /// It provides the necessary typedefs required by the map concept. - template + template class MapBase { public: - /// \e - typedef _NeedCopy NeedCopy; ///\e typedef K Key; ///\e @@ -54,10 +52,10 @@ /// If you have to provide a map only for its type definitions, /// or if you have to provide a writable map, but /// data written to it will sent to /dev/null... - template - class NullMap : public MapBase { + template + class NullMap : public MapBase { public: - typedef MapBase Parent; + typedef MapBase Parent; typedef typename Parent::Key Key; typedef typename Parent::Value Value; @@ -68,8 +66,8 @@ }; template - NullMap nullMap() { - return NullMap(); + NullMap nullMap() { + return NullMap(); } @@ -78,13 +76,13 @@ /// This is a readable map which assigns a specified value to each key. /// In other aspects it is equivalent to the \ref NullMap. /// \todo set could be used to set the value. - template - class ConstMap : public MapBase { + template + class ConstMap : public MapBase { private: T v; public: - typedef MapBase Parent; + typedef MapBase Parent; typedef typename Parent::Key Key; typedef typename Parent::Value Value; @@ -116,8 +114,8 @@ ///This function just returns a \ref ConstMap class. ///\relates ConstMap template - inline ConstMap constMap(const V &v) { - return ConstMap(v); + inline ConstMap constMap(const V &v) { + return ConstMap(v); } @@ -126,10 +124,10 @@ struct Const { }; //\todo to document later - template - class ConstMap, NC > : public MapBase { + template + class ConstMap > : public MapBase { public: - typedef MapBase Parent; + typedef MapBase Parent; typedef typename Parent::Key Key; typedef typename Parent::Value Value; @@ -143,8 +141,8 @@ ///This function just returns a \ref ConstMap class. ///\relates ConstMap template - inline ConstMap, True> constMap() { - return ConstMap, True>(); + inline ConstMap > constMap() { + return ConstMap >(); } /// \c std::map wrapper @@ -225,10 +223,10 @@ /// /// This mapping gives back the given key as value without any /// modification. - template - class IdentityMap : public MapBase { + template + class IdentityMap : public MapBase { public: - typedef MapBase Parent; + typedef MapBase Parent; typedef typename Parent::Key Key; typedef typename Parent::Value Value; @@ -242,8 +240,8 @@ ///This function just returns an \ref IdentityMap class. ///\relates IdentityMap template - inline IdentityMap identityMap() { - return IdentityMap(); + inline IdentityMap identityMap() { + return IdentityMap(); } @@ -252,11 +250,11 @@ ///This \ref concept::ReadMap "read only map" ///converts the \c Value of a maps to type \c T. ///Its \c Key is inherited from \c M. - template - class ConvertMap : public MapBase { - typename SmartConstReference::Type m; + template + class ConvertMap : public MapBase { + const M& m; public: - typedef MapBase Parent; + typedef MapBase Parent; typedef typename Parent::Key Key; typedef typename Parent::Value Value; @@ -280,8 +278,8 @@ ///\relates ConvertMap ///\todo The order of the template parameters are changed. template - inline ConvertMap convertMap(const M &m) { - return ConvertMap(m); + inline ConvertMap convertMap(const M &m) { + return ConvertMap(m); } ///Sum of two maps @@ -290,13 +288,13 @@ ///given maps. Its \c Key and \c Value will be inherited from \c M1. ///The \c Key and \c Value of M2 must be convertible to those of \c M1. - template - class AddMap : public MapBase { - typename SmartConstReference::Type m1; - typename SmartConstReference::Type m2; + template + class AddMap : public MapBase { + const M1& m1; + const M2& m2; public: - typedef MapBase Parent; + typedef MapBase Parent; typedef typename Parent::Key Key; typedef typename Parent::Value Value; @@ -313,8 +311,8 @@ ///\relates AddMap ///\todo Wrong scope in Doxygen when \c \\relates is used template - inline AddMap addMap(const M1 &m1,const M2 &m2) { - return AddMap(m1,m2); + inline AddMap addMap(const M1 &m1,const M2 &m2) { + return AddMap(m1,m2); } ///Shift a map with a constant. @@ -332,12 +330,12 @@ /// ConstMap c_tmp(v); /// AddMap > sh(x,v); ///\endcode - template - class ShiftMap : public MapBase { - typename SmartConstReference::Type m; + template + class ShiftMap : public MapBase { + const M& m; C v; public: - typedef MapBase Parent; + typedef MapBase Parent; typedef typename Parent::Key Key; typedef typename Parent::Value Value; @@ -356,8 +354,8 @@ ///\relates ShiftMap ///\todo A better name is required. template - inline ShiftMap shiftMap(const M &m,const C &v) { - return ShiftMap(m,v); + inline ShiftMap shiftMap(const M &m,const C &v) { + return ShiftMap(m,v); } ///Difference of two maps @@ -367,12 +365,12 @@ ///given maps. Its \c Key and \c Value will be inherited from \c M1. ///The \c Key and \c Value of \c M2 must be convertible to those of \c M1. - template - class SubMap : public MapBase { - typename SmartConstReference::Type m1; - typename SmartConstReference::Type m2; + template + class SubMap : public MapBase { + const M1& m1; + const M2& m2; public: - typedef MapBase Parent; + typedef MapBase Parent; typedef typename Parent::Key Key; typedef typename Parent::Value Value; @@ -387,8 +385,8 @@ /// ///\relates SubMap template - inline SubMap subMap(const M1 &m1, const M2 &m2) { - return SubMap(m1, m2); + inline SubMap subMap(const M1 &m1, const M2 &m2) { + return SubMap(m1, m2); } ///Product of two maps @@ -399,12 +397,12 @@ ///maps. Its \c Key and \c Value will be inherited from \c M1. ///The \c Key and \c Value of \c M2 must be convertible to those of \c M1. - template - class MulMap : public MapBase { - typename SmartConstReference::Type m1; - typename SmartConstReference::Type m2; + template + class MulMap : public MapBase { + const M1& m1; + const M2& m2; public: - typedef MapBase Parent; + typedef MapBase Parent; typedef typename Parent::Key Key; typedef typename Parent::Value Value; @@ -418,8 +416,8 @@ ///This function just returns a \ref MulMap class. ///\relates MulMap template - inline MulMap mulMap(const M1 &m1,const M2 &m2) { - return MulMap(m1,m2); + inline MulMap mulMap(const M1 &m1,const M2 &m2) { + return MulMap(m1,m2); } ///Scales a maps with a constant. @@ -437,12 +435,12 @@ /// ConstMap c_tmp(v); /// MulMap > sc(x,v); ///\endcode - template - class ScaleMap : public MapBase { - typename SmartConstReference::Type m; + template + class ScaleMap : public MapBase { + const M& m; C v; public: - typedef MapBase Parent; + typedef MapBase Parent; typedef typename Parent::Key Key; typedef typename Parent::Value Value; @@ -461,8 +459,8 @@ ///\relates ScaleMap ///\todo A better name is required. template - inline ScaleMap scaleMap(const M &m,const C &v) { - return ScaleMap(m,v); + inline ScaleMap scaleMap(const M &m,const C &v) { + return ScaleMap(m,v); } ///Quotient of two maps @@ -472,12 +470,12 @@ ///given maps. Its \c Key and \c Value will be inherited from \c M1. ///The \c Key and \c Value of \c M2 must be convertible to those of \c M1. - template - class DivMap : public MapBase { - typename SmartConstReference::Type m1; - typename SmartConstReference::Type m2; + template + class DivMap : public MapBase { + const M1& m1; + const M2& m2; public: - typedef MapBase Parent; + typedef MapBase Parent; typedef typename Parent::Key Key; typedef typename Parent::Value Value; @@ -491,8 +489,8 @@ ///This function just returns a \ref DivMap class. ///\relates DivMap template - inline DivMap divMap(const M1 &m1,const M2 &m2) { - return DivMap(m1,m2); + inline DivMap divMap(const M1 &m1,const M2 &m2) { + return DivMap(m1,m2); } ///Composition of two maps @@ -512,12 +510,12 @@ ///The \c M2::Value must be convertible to \c M1::Key. ///\todo Check the requirements. - template - class ComposeMap : public MapBase { - typename SmartConstReference::Type m1; - typename SmartConstReference::Type m2; + template + class ComposeMap : public MapBase { + const M1& m1; + const M2& m2; public: - typedef MapBase Parent; + typedef MapBase Parent; typedef typename Parent::Key Key; typedef typename Parent::Value Value; @@ -531,8 +529,8 @@ /// ///\relates ComposeMap template - inline ComposeMap composeMap(const M1 &m1,const M2 &m2) { - return ComposeMap(m1,m2); + inline ComposeMap composeMap(const M1 &m1,const M2 &m2) { + return ComposeMap(m1,m2); } ///Combines of two maps using an STL (binary) functor. @@ -561,12 +559,12 @@ template - class CombineMap : public MapBase { - typename SmartConstReference::Type m1; - typename SmartConstReference::Type m2; + class CombineMap : public MapBase { + const M1& m1; + const M2& m2; F f; public: - typedef MapBase Parent; + typedef MapBase Parent; typedef typename Parent::Key Key; typedef typename Parent::Value Value; @@ -593,19 +591,19 @@ /// ///\relates CombineMap template - inline CombineMap + inline CombineMap combineMap(const M1& m1,const M2& m2, const F& f) { - return CombineMap(m1,m2,f); + return CombineMap(m1,m2,f); } template - inline CombineMap + inline CombineMap combineMap(const M1& m1, const M2& m2, const F& f) { return combineMap(m1,m2,f); } template - inline CombineMap + inline CombineMap combineMap(const M1 &m1, const M2 &m2, V (*f)(K1, K2)) { return combineMap(m1,m2,f); } @@ -618,11 +616,11 @@ ///given map. Its \c Key and \c Value will be inherited from \c M. ///The unary \c - operator must be defined for \c Value, of course. - template - class NegMap : public MapBase { - typename SmartConstReference::Type m; + template + class NegMap : public MapBase { + const M& m; public: - typedef MapBase Parent; + typedef MapBase Parent; typedef typename Parent::Key Key; typedef typename Parent::Value Value; @@ -636,8 +634,8 @@ ///This function just returns a \ref NegMap class. ///\relates NegMap template - inline NegMap negMap(const M &m) { - return NegMap(m); + inline NegMap negMap(const M &m) { + return NegMap(m); } @@ -664,11 +662,11 @@ ///\endcode - template - class AbsMap : public MapBase { - typename SmartConstReference::Type m; + template + class AbsMap : public MapBase { + const M& m; public: - typedef MapBase Parent; + typedef MapBase Parent; typedef typename Parent::Key Key; typedef typename Parent::Value Value; @@ -686,8 +684,8 @@ ///This function just returns a \ref AbsMap class. ///\relates AbsMap template - inline AbsMap absMap(const M &m) { - return AbsMap(m); + inline AbsMap absMap(const M &m) { + return AbsMap(m); } ///Converts an STL style functor to a map @@ -707,10 +705,10 @@ typename K = typename F::argument_type, typename V = typename F::result_type, typename NC = False> - class FunctorMap : public MapBase { + class FunctorMap : public MapBase { F f; public: - typedef MapBase Parent; + typedef MapBase Parent; typedef typename Parent::Key Key; typedef typename Parent::Value Value; @@ -727,20 +725,20 @@ ///The third template parameter isn't necessary to be given. ///\relates FunctorMap template inline - FunctorMap functorMap(const F &f) { - return FunctorMap(f); + FunctorMap functorMap(const F &f) { + return FunctorMap(f); } template inline - FunctorMap + FunctorMap functorMap(const F &f) { return FunctorMap(f); + typename F::result_type>(f); } template inline - FunctorMap functorMap(V (*f)(K)) { - return FunctorMap(f); + FunctorMap functorMap(V (*f)(K)) { + return FunctorMap(f); } @@ -753,11 +751,11 @@ ///a ususal \ref concept::ReadMap "readable map", ///i.e. operator[] and the \c Key and \c Value typedefs also exist. - template - class MapFunctor : public MapBase { - typename SmartConstReference::Type m; + template + class MapFunctor : public MapBase { + const M& m; public: - typedef MapBase Parent; + typedef MapBase Parent; typedef typename Parent::Key Key; typedef typename Parent::Value Value; @@ -779,8 +777,8 @@ ///This function just returns a \ref MapFunctor class. ///\relates MapFunctor template - inline MapFunctor mapFunctor(const M &m) { - return MapFunctor(m); + inline MapFunctor mapFunctor(const M &m) { + return MapFunctor(m); } @@ -795,12 +793,12 @@ ///The \c Key and \c Value will be inherited from \c M1. ///The \c Key and \c Value of M2 must be convertible from those of \c M1. - template - class ForkMap : public MapBase { - typename SmartConstReference::Type m1; - typename SmartConstReference::Type m2; + template + class ForkMap : public MapBase { + const M1& m1; + const M2& m2; public: - typedef MapBase Parent; + typedef MapBase Parent; typedef typename Parent::Key Key; typedef typename Parent::Value Value; @@ -818,8 +816,8 @@ ///\relates ForkMap ///\todo Wrong scope in Doxygen when \c \\relates is used template - inline ForkMap forkMap(const M1 &m1,const M2 &m2) { - return ForkMap(m1,m2); + inline ForkMap forkMap(const M1 &m1,const M2 &m2) { + return ForkMap(m1,m2); } @@ -834,11 +832,11 @@ ///given map. Its \c Key and will be inherited from \c M, ///its Value is bool. - template - class NotMap : public MapBase { - typename SmartConstReference::Type m; + template + class NotMap : public MapBase { + const M& m; public: - typedef MapBase Parent; + typedef MapBase Parent; typedef typename Parent::Key Key; typedef typename Parent::Value Value; @@ -852,8 +850,8 @@ ///This function just returns a \ref NotMap class. ///\relates NotMap template - inline NotMap notMap(const M &m) { - return NotMap(m); + inline NotMap notMap(const M &m) { + return NotMap(m); } /// @} diff -r 467d7927a901 -r 3f63d9db307b lemon/utility.h --- a/lemon/utility.h Wed Oct 05 13:17:42 2005 +0000 +++ b/lemon/utility.h Wed Oct 05 13:18:51 2005 +0000 @@ -139,47 +139,6 @@ template struct lazy_disable_if : public lazy_disable_if_c {}; - // smart referencing - - template - struct SmartReference { - typedef _Type& Type; - }; - - template - struct SmartReference< - _Type, - typename enable_if::type - > { - typedef _Type Type; - }; - - template - struct SmartConstReference { - typedef const _Type& Type; - }; - - template - struct SmartConstReference< - _Type, - typename enable_if::type - > { - typedef const _Type Type; - }; - - template - struct SmartParameter { - typedef _Type& Type; - }; - - template - struct SmartParameter< - _Type, - typename enable_if::type - > { - typedef const _Type& Type; - }; - } // namespace lemon #endif