lemon/concepts/maps.h
changeset 113 18a7ee8fa56e
parent 79 d73c2e8b25cb
child 114 c837d1e449dc
equal deleted inserted replaced
7:8e0bf057246b 8:6363613044ce
    45       typedef K Key;
    45       typedef K Key;
    46       /// The value type of the map. (The type of objects associated with the keys).
    46       /// The value type of the map. (The type of objects associated with the keys).
    47       typedef T Value;
    47       typedef T Value;
    48 
    48 
    49       /// Returns the value associated with the given key.
    49       /// Returns the value associated with the given key.
    50 
    50       Value operator[](const Key &) const { 
    51       /// Returns the value associated with the given key.
    51         return *static_cast<Value *>(0);
    52       /// \bug Value shouldn't need to be default constructible. 
    52       }
    53       Value operator[](const Key &) const { return Value(); }
       
    54 
    53 
    55       template<typename _ReadMap>
    54       template<typename _ReadMap>
    56       struct Constraints {
    55       struct Constraints {
    57 	void constraints() {
    56 	void constraints() {
    58 	  Value val = m[key];
    57 	  Value val = m[key];
   124       typedef K Key;
   123       typedef K Key;
   125       /// The value type of the map. (The type of objects associated with the keys).
   124       /// The value type of the map. (The type of objects associated with the keys).
   126       typedef T Value;
   125       typedef T Value;
   127 
   126 
   128       /// Returns the value associated with the given key.
   127       /// Returns the value associated with the given key.
   129       Value operator[](const Key &) const { return Value(); }
   128       Value operator[](const Key &) const { 
       
   129         return *static_cast<Value *>(0);
       
   130       }
   130 
   131 
   131       /// Sets the value associated with the given key.
   132       /// Sets the value associated with the given key.
   132       void set(const Key &, const Value &) {}
   133       void set(const Key &, const Value &) {}
   133 
   134 
   134       template<typename _ReadWriteMap>
   135       template<typename _ReadWriteMap>
   158       /// The reference type of the map.
   159       /// The reference type of the map.
   159       typedef R Reference;
   160       typedef R Reference;
   160       /// The const reference type of the map.
   161       /// The const reference type of the map.
   161       typedef CR ConstReference;
   162       typedef CR ConstReference;
   162 
   163 
   163     protected:
       
   164       Value tmp;
       
   165     public:
   164     public:
   166 
   165 
   167       /// Returns a reference to the value associated with the given key.
   166       /// Returns a reference to the value associated with the given key.
   168       Reference operator[](const Key &) { return tmp; }
   167       Reference operator[](const Key &) { 
       
   168         return *static_cast<Value *>(0);
       
   169       }
   169 
   170 
   170       /// Returns a const reference to the value associated with the given key.
   171       /// Returns a const reference to the value associated with the given key.
   171       ConstReference operator[](const Key &) const { return tmp; }
   172       ConstReference operator[](const Key &) const {
       
   173         return *static_cast<Value *>(0);
       
   174       }
   172 
   175 
   173       /// Sets the value associated with the given key.
   176       /// Sets the value associated with the given key.
   174       void set(const Key &k,const Value &t) { operator[](k)=t; }
   177       void set(const Key &k,const Value &t) { operator[](k)=t; }
   175 
   178 
   176       template<typename _ReferenceMap>
   179       template<typename _ReferenceMap>