lemon/concepts/maps.h
changeset 1433 a278d16bd2d0
parent 1270 dceba191c00d
equal deleted inserted replaced
26:4e010883f777 27:46032b2c263d
    47       /// (The type of objects associated with the keys).
    47       /// (The type of objects associated with the keys).
    48       typedef T Value;
    48       typedef T Value;
    49 
    49 
    50       /// Returns the value associated with the given key.
    50       /// Returns the value associated with the given key.
    51       Value operator[](const Key &) const {
    51       Value operator[](const Key &) const {
    52         return *(static_cast<Value *>(0)+1);
    52         // return *(static_cast<Value *>(0));
       
    53         // return *(static_cast<Value *>(0)+1);
       
    54         // return *(static_cast<Value *>(sizeof(Value)));
       
    55         // return *(reinterpret_cast<Value *>(0));
       
    56         // return *(reinterpret_cast<Value *>(0)+1);
       
    57         return *(reinterpret_cast<Value *>(sizeof(Value)));
    53       }
    58       }
    54 
    59 
    55       template<typename _ReadMap>
    60       template<typename _ReadMap>
    56       struct Constraints {
    61       struct Constraints {
    57         void constraints() {
    62         void constraints() {
   129       /// (The type of objects associated with the keys).
   134       /// (The type of objects associated with the keys).
   130       typedef T Value;
   135       typedef T Value;
   131 
   136 
   132       /// Returns the value associated with the given key.
   137       /// Returns the value associated with the given key.
   133       Value operator[](const Key &) const {
   138       Value operator[](const Key &) const {
   134         Value *r = 0;
   139         return *(reinterpret_cast<Value *>(sizeof(Value)));
   135         return *r;
       
   136       }
   140       }
   137 
   141 
   138       /// Sets the value associated with the given key.
   142       /// Sets the value associated with the given key.
   139       void set(const Key &, const Value &) {}
   143       void set(const Key &, const Value &) {}
   140 
   144 
   170 
   174 
   171     public:
   175     public:
   172 
   176 
   173       /// Returns a reference to the value associated with the given key.
   177       /// Returns a reference to the value associated with the given key.
   174       Reference operator[](const Key &) {
   178       Reference operator[](const Key &) {
   175         Value *r = 0;
   179         return *(reinterpret_cast<Value *>(sizeof(Value)));
   176         return *r;
       
   177       }
   180       }
   178 
   181 
   179       /// Returns a const reference to the value associated with the given key.
   182       /// Returns a const reference to the value associated with the given key.
   180       ConstReference operator[](const Key &) const {
   183       ConstReference operator[](const Key &) const {
   181         Value *r = 0;
   184         return *(reinterpret_cast<Value *>(sizeof(Value)));
   182         return *r;
       
   183       }
   185       }
   184 
   186 
   185       /// Sets the value associated with the given key.
   187       /// Sets the value associated with the given key.
   186       void set(const Key &k,const Value &t) { operator[](k)=t; }
   188       void set(const Key &k,const Value &t) { operator[](k)=t; }
   187 
   189