# HG changeset patch
# User Peter Kovacs <kpeter@inf.elte.hu>
# Date 1207687886 -7200
# Node ID 8899d1891a3c63a87d251d8dde847c308e741c34
# Parent  b6bede534255e492871c601771442b65e12f7319
Small improvements in maps.h
- Add a new version of constMap() function.
- Fix in FunctorToMap class.

diff -r b6bede534255 -r 8899d1891a3c lemon/maps.h
--- a/lemon/maps.h	Thu Apr 03 13:00:18 2008 +0100
+++ b/lemon/maps.h	Tue Apr 08 22:51:26 2008 +0200
@@ -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<K, V>(v);
   }
 
+  template<typename K, typename V>
+  inline ConstMap<K, V> constMap() {
+    return ConstMap<K, V>();
+  }
+
 
   template<typename T, T v>
   struct Const {};
@@ -613,7 +618,7 @@
 	   typename K = typename F::argument_type,
 	   typename V = typename F::result_type>
   class FunctorToMap : public MapBase<K, V> {
-    const F &_f;
+    F _f;
   public:
     typedef MapBase<K, V> Parent;
     typedef typename Parent::Key Key;
diff -r b6bede534255 -r 8899d1891a3c test/maps_test.cc
--- a/test/maps_test.cc	Thu Apr 03 13:00:18 2008 +0100
+++ b/test/maps_test.cc	Tue Apr 08 22:51:26 2008 +0200
@@ -83,20 +83,27 @@
   // ConstMap
   {
     checkConcept<ReadWriteMap<A,B>, ConstMap<A,B> >();
+    checkConcept<ReadWriteMap<A,C>, ConstMap<A,C> >();
     ConstMap<A,B> map1;
     ConstMap<A,B> map2(B());
     ConstMap<A,B> map3 = map1;
     map1 = constMap<A>(B());
+    map1 = constMap<A,B>();
     map1.setAll(B());
+    ConstMap<A,C> map4(C(1));
+    ConstMap<A,C> map5 = map4;
+    map4 = constMap<A>(C(2));
+    map4.setAll(C(3));
 
     checkConcept<ReadWriteMap<A,int>, ConstMap<A,int> >();
     check(constMap<A>(10)[A()] == 10, "Something is wrong with ConstMap");
 
     checkConcept<ReadWriteMap<A,int>, ConstMap<A,Const<int,10> > >();
-    ConstMap<A,Const<int,10> > map4;
-    ConstMap<A,Const<int,10> > map5 = map4;
-    map4 = map5;
-    check(map4[A()] == 10 && map5[A()] == 10, "Something is wrong with ConstMap");
+    ConstMap<A,Const<int,10> > map6;
+    ConstMap<A,Const<int,10> > map7 = map6;
+    map6 = constMap<A,int,10>();
+    map7 = constMap<A,Const<int,10> >();
+    check(map6[A()] == 10 && map7[A()] == 10, "Something is wrong with ConstMap");
   }
 
   // IdentityMap