[Lemon-commits] deba: r3260 - lemon/trunk/lemon

Lemon SVN svn at lemon.cs.elte.hu
Thu Apr 19 17:09:09 CEST 2007


Author: deba
Date: Thu Apr 19 17:09:08 2007
New Revision: 3260

Modified:
   lemon/trunk/lemon/maps.h

Log:
Corrections on StoreBoolMap
 - *insert_iterator has void value_type
 - use const setting



Modified: lemon/trunk/lemon/maps.h
==============================================================================
--- lemon/trunk/lemon/maps.h	(original)
+++ lemon/trunk/lemon/maps.h	Thu Apr 19 17:09:08 2007
@@ -1044,21 +1044,35 @@
   inline NotMap<M> notMap(const M &m) {
     return NotMap<M>(m);
   }
-
+  
   template <typename M> 
   inline NotWriteMap<M> notMap(M &m) {
     return NotWriteMap<M>(m);
   }
 
   namespace _maps_bits {
+
     template <typename Value>
     struct Identity {
       typedef Value argument_type;
       typedef Value result_type;
-      Value operator()(const Value& val) {
+      Value operator()(const Value& val) const {
 	return val;
       }
     };
+
+    template <typename _Iterator, typename Enable = void>
+    struct IteratorTraits {
+      typedef typename std::iterator_traits<_Iterator>::value_type Value;
+    };
+
+    template <typename _Iterator>
+    struct IteratorTraits<_Iterator,
+      typename exists<typename _Iterator::container_type>::type> 
+    {
+      typedef typename _Iterator::container_type::value_type Value;
+    };
+
   }
   
 
@@ -1085,8 +1099,9 @@
   /// prim(ugraph, cost, writerMap);
   ///\endcode
   template <typename _Iterator, 
-            typename _Functor = 
-            _maps_bits::Identity<typename std::iterator_traits<_Iterator>::value_type> >
+            typename _Functor =
+            _maps_bits::Identity<typename _maps_bits::
+                                 IteratorTraits<_Iterator>::Value> >
   class StoreBoolMap {
   public:
     typedef _Iterator Iterator;
@@ -1111,14 +1126,15 @@
     }
 
     /// Setter function of the map
-    void set(const Key& key, Value value) {
+    void set(const Key& key, Value value) const {
       if (value) {
 	*_end++ = _functor(key);
       }
     }
     
   private:
-    Iterator _begin, _end;
+    Iterator _begin;
+    mutable Iterator _end;
     Functor _functor;
   };
 



More information about the Lemon-commits mailing list