# HG changeset patch # User Peter Kovacs # Date 2008-04-08 22:51:26 # Node ID 8899d1891a3c63a87d251d8dde847c308e741c34 # Parent b6bede534255e492871c601771442b65e12f7319 Small improvements in maps.h - Add a new version of constMap() function. - Fix in FunctorToMap class. diff --git a/lemon/maps.h b/lemon/maps.h --- a/lemon/maps.h +++ b/lemon/maps.h @@ -116,7 +116,7 @@ /// Constructor with specified initial value /// Constructor with specified initial value. - /// \param v is the initial value of the map. + /// \param v The initial value of the map. ConstMap(const Value &v) : _value(v) {} /// Gives back the specified value. @@ -143,6 +143,11 @@ return ConstMap(v); } + template + inline ConstMap constMap() { + return ConstMap(); + } + template struct Const {}; @@ -613,7 +618,7 @@ typename K = typename F::argument_type, typename V = typename F::result_type> class FunctorToMap : public MapBase { - const F &_f; + F _f; public: typedef MapBase Parent; typedef typename Parent::Key Key; diff --git a/test/maps_test.cc b/test/maps_test.cc --- a/test/maps_test.cc +++ b/test/maps_test.cc @@ -83,20 +83,27 @@ // ConstMap { checkConcept, ConstMap >(); + checkConcept, ConstMap >(); ConstMap map1; ConstMap map2(B()); ConstMap map3 = map1; map1 = constMap(B()); + map1 = constMap(); map1.setAll(B()); + ConstMap map4(C(1)); + ConstMap map5 = map4; + map4 = constMap(C(2)); + map4.setAll(C(3)); checkConcept, ConstMap >(); check(constMap(10)[A()] == 10, "Something is wrong with ConstMap"); checkConcept, ConstMap > >(); - ConstMap > map4; - ConstMap > map5 = map4; - map4 = map5; - check(map4[A()] == 10 && map5[A()] == 10, "Something is wrong with ConstMap"); + ConstMap > map6; + ConstMap > map7 = map6; + map6 = constMap(); + map7 = constMap >(); + check(map6[A()] == 10 && map7[A()] == 10, "Something is wrong with ConstMap"); } // IdentityMap