lemon/concepts/maps.h
changeset 94 a4688e4138ec
parent 79 d73c2e8b25cb
child 114 c837d1e449dc
     1.1 --- a/lemon/concepts/maps.h	Mon Mar 17 19:21:27 2008 +0000
     1.2 +++ b/lemon/concepts/maps.h	Tue Mar 18 13:57:15 2008 +0100
     1.3 @@ -47,10 +47,9 @@
     1.4        typedef T Value;
     1.5  
     1.6        /// Returns the value associated with the given key.
     1.7 -
     1.8 -      /// Returns the value associated with the given key.
     1.9 -      /// \bug Value shouldn't need to be default constructible. 
    1.10 -      Value operator[](const Key &) const { return Value(); }
    1.11 +      Value operator[](const Key &) const { 
    1.12 +        return *static_cast<Value *>(0);
    1.13 +      }
    1.14  
    1.15        template<typename _ReadMap>
    1.16        struct Constraints {
    1.17 @@ -126,7 +125,9 @@
    1.18        typedef T Value;
    1.19  
    1.20        /// Returns the value associated with the given key.
    1.21 -      Value operator[](const Key &) const { return Value(); }
    1.22 +      Value operator[](const Key &) const { 
    1.23 +        return *static_cast<Value *>(0);
    1.24 +      }
    1.25  
    1.26        /// Sets the value associated with the given key.
    1.27        void set(const Key &, const Value &) {}
    1.28 @@ -160,15 +161,17 @@
    1.29        /// The const reference type of the map.
    1.30        typedef CR ConstReference;
    1.31  
    1.32 -    protected:
    1.33 -      Value tmp;
    1.34      public:
    1.35  
    1.36        /// Returns a reference to the value associated with the given key.
    1.37 -      Reference operator[](const Key &) { return tmp; }
    1.38 +      Reference operator[](const Key &) { 
    1.39 +        return *static_cast<Value *>(0);
    1.40 +      }
    1.41  
    1.42        /// Returns a const reference to the value associated with the given key.
    1.43 -      ConstReference operator[](const Key &) const { return tmp; }
    1.44 +      ConstReference operator[](const Key &) const {
    1.45 +        return *static_cast<Value *>(0);
    1.46 +      }
    1.47  
    1.48        /// Sets the value associated with the given key.
    1.49        void set(const Key &k,const Value &t) { operator[](k)=t; }