Index: lemon/concepts/maps.h
===================================================================
--- lemon/concepts/maps.h	(revision 74)
+++ lemon/concepts/maps.h	(revision 94)
@@ -30,5 +30,5 @@
 
   namespace concepts {
-  
+
     /// \addtogroup concept
     /// @{
@@ -43,14 +43,12 @@
     public:
       /// The key type of the map.
-      typedef K Key;    
-      /// The value type of the map. (The type of objects associated with the keys).
-      typedef T Value;
-
-      /// Returns the value associated with a key.
-
-      /// Returns the value associated with a key.
-      /// \bug Value shouldn't need to be default constructible.
-      ///
-      Value operator[](const Key &) const {return Value();}
+      typedef K Key;
+      /// The value type of the map. (The type of objects associated with the keys).
+      typedef T Value;
+
+      /// Returns the value associated with the given key.
+      Value operator[](const Key &) const { 
+        return *static_cast<Value *>(0);
+      }
 
       template<typename _ReadMap>
@@ -59,44 +57,7 @@
 	  Value val = m[key];
 	  val = m[key];
-	  typename _ReadMap::Value own_val = m[own_key]; 
-	  own_val = m[own_key]; 
-
-	  ignore_unused_variable_warning(val);
-	  ignore_unused_variable_warning(own_val);
-	  ignore_unused_variable_warning(key);
-	}
-	Key& key;
-	typename _ReadMap::Key& own_key;
-	_ReadMap& m;
-      };
-      
-    };
-
-
-    /// Writable map concept
-    
-    /// Writable map concept.
-    ///
-    template<typename K, typename T>
-    class WriteMap
-    {
-    public:
-      /// The key type of the map.
-      typedef K Key;    
-      /// The value type of the map. (The type of objects associated with the keys).
-      typedef T Value;
-
-      /// Sets the value associated with a key.
-      void set(const Key &,const Value &) {}
-
-      ///Default constructor
-      WriteMap() {}
-
-      template <typename _WriteMap>
-      struct Constraints {
-	void constraints() {
-	  // No constraints for constructor.
-	  m.set(key, val);
-	  m.set(own_key, own_val);
+	  typename _ReadMap::Value own_val = m[own_key];
+	  own_val = m[own_key];
+
 	  ignore_unused_variable_warning(key);
 	  ignore_unused_variable_warning(val);
@@ -104,16 +65,52 @@
 	  ignore_unused_variable_warning(own_val);
 	}
-
-	Value& val;
-	typename _WriteMap::Value own_val;
-	Key& key;
-	typename _WriteMap::Key& own_key;
+	const Key& key;
+	const typename _ReadMap::Key& own_key;
+	const _ReadMap& m;
+      };
+
+    };
+
+
+    /// Writable map concept
+
+    /// Writable map concept.
+    ///
+    template<typename K, typename T>
+    class WriteMap
+    {
+    public:
+      /// The key type of the map.
+      typedef K Key;
+      /// The value type of the map. (The type of objects associated with the keys).
+      typedef T Value;
+
+      /// Sets the value associated with the given key.
+      void set(const Key &, const Value &) {}
+
+      /// Default constructor.
+      WriteMap() {}
+
+      template <typename _WriteMap>
+      struct Constraints {
+	void constraints() {
+	  m.set(key, val);
+	  m.set(own_key, own_val);
+
+	  ignore_unused_variable_warning(key);
+	  ignore_unused_variable_warning(val);
+	  ignore_unused_variable_warning(own_key);
+	  ignore_unused_variable_warning(own_val);
+	}
+	const Key& key;
+	const Value& val;
+	const typename _WriteMap::Key& own_key;
+	const typename _WriteMap::Value own_val;
 	_WriteMap& m;
-
       };
     };
 
     /// Read/writable map concept
-    
+
     /// Read/writable map concept.
     ///
@@ -124,12 +121,15 @@
     public:
       /// The key type of the map.
-      typedef K Key;    
-      /// The value type of the map. (The type of objects associated with the keys).
-      typedef T Value;
-
-      /// Returns the value associated with a key.
-      Value operator[](const Key &) const {return Value();}
-      /// Sets the value associated with a key.
-      void set(const Key & ,const Value &) {}
+      typedef K Key;
+      /// The value type of the map. (The type of objects associated with the keys).
+      typedef T Value;
+
+      /// Returns the value associated with the given key.
+      Value operator[](const Key &) const { 
+        return *static_cast<Value *>(0);
+      }
+
+      /// Sets the value associated with the given key.
+      void set(const Key &, const Value &) {}
 
       template<typename _ReadWriteMap>
@@ -141,11 +141,10 @@
       };
     };
-  
-  
+
+
     /// Dereferable map concept
-    
+
     /// Dereferable map concept.
     ///
-    /// \todo Rethink this concept.
     template<typename K, typename T, typename R, typename CR>
     class ReferenceMap : public ReadWriteMap<K,T>
@@ -155,5 +154,5 @@
       typedef True ReferenceMapTag;
       /// The key type of the map.
-      typedef K Key;    
+      typedef K Key;
       /// The value type of the map. (The type of objects associated with the keys).
       typedef T Value;
@@ -163,13 +162,17 @@
       typedef CR ConstReference;
 
-    protected:
-      Value tmp;
-    public:
-
-      ///Returns a reference to the value associated with a key.
-      Reference operator[](const Key &) { return tmp; }
-      ///Returns a const reference to the value associated with a key.
-      ConstReference operator[](const Key &) const { return tmp; }
-      /// Sets the value associated with a key.
+    public:
+
+      /// Returns a reference to the value associated with the given key.
+      Reference operator[](const Key &) { 
+        return *static_cast<Value *>(0);
+      }
+
+      /// Returns a const reference to the value associated with the given key.
+      ConstReference operator[](const Key &) const {
+        return *static_cast<Value *>(0);
+      }
+
+      /// Sets the value associated with the given key.
       void set(const Key &k,const Value &t) { operator[](k)=t; }
 
@@ -178,20 +181,23 @@
 	void constraints() {
 	  checkConcept<ReadWriteMap<K, T>, _ReferenceMap >();
+	  ref = m[key];
 	  m[key] = val;
-	  val  = m[key];
 	  m[key] = ref;
-	  ref = m[key];
+	  m[key] = cref;
+	  own_ref = m[own_key];
 	  m[own_key] = own_val;
-	  own_val  = m[own_key];
 	  m[own_key] = own_ref;
-	  own_ref = m[own_key];	  	  
-	}
-
-	typename _ReferenceMap::Key& own_key;
+	  m[own_key] = own_cref;
+	  m[key] = m[own_key];
+	  m[own_key] = m[key];
+	}
+	const Key& key;
+	Value& val;
+	Reference ref;
+	ConstReference cref;
+	const typename _ReferenceMap::Key& own_key;
 	typename _ReferenceMap::Value& own_val;
 	typename _ReferenceMap::Reference own_ref;
-	Key& key;
-	Value& val;
-	Reference ref;
+	typename _ReferenceMap::ConstReference own_cref;
 	_ReferenceMap& m;
       };
