Changeset 209:765619b7cbb2 in lemon-1.2 for lemon/concepts/maps.h
- Timestamp:
- 07/13/08 20:51:02 (17 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
lemon/concepts/maps.h
r114 r209 1 /* -*- C++-*-2 * 3 * This file is a part of LEMON, a generic C++ optimization library 1 /* -*- mode: C++; indent-tabs-mode: nil; -*- 2 * 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 5 * Copyright (C) 2003-2008 … … 48 48 49 49 /// Returns the value associated with the given key. 50 Value operator[](const Key &) const { 50 Value operator[](const Key &) const { 51 51 return *static_cast<Value *>(0); 52 52 } … … 54 54 template<typename _ReadMap> 55 55 struct Constraints { 56 57 58 59 60 61 62 63 64 65 66 67 68 69 56 void constraints() { 57 Value val = m[key]; 58 val = m[key]; 59 typename _ReadMap::Value own_val = m[own_key]; 60 own_val = m[own_key]; 61 62 ignore_unused_variable_warning(key); 63 ignore_unused_variable_warning(val); 64 ignore_unused_variable_warning(own_key); 65 ignore_unused_variable_warning(own_val); 66 } 67 const Key& key; 68 const typename _ReadMap::Key& own_key; 69 const _ReadMap& m; 70 70 }; 71 71 … … 94 94 template <typename _WriteMap> 95 95 struct Constraints { 96 97 98 99 100 101 102 103 104 105 106 107 108 109 96 void constraints() { 97 m.set(key, val); 98 m.set(own_key, own_val); 99 100 ignore_unused_variable_warning(key); 101 ignore_unused_variable_warning(val); 102 ignore_unused_variable_warning(own_key); 103 ignore_unused_variable_warning(own_val); 104 } 105 const Key& key; 106 const Value& val; 107 const typename _WriteMap::Key& own_key; 108 const typename _WriteMap::Value& own_val; 109 _WriteMap& m; 110 110 }; 111 111 }; … … 117 117 template<typename K, typename T> 118 118 class ReadWriteMap : public ReadMap<K,T>, 119 119 public WriteMap<K,T> 120 120 { 121 121 public: … … 126 126 127 127 /// Returns the value associated with the given key. 128 Value operator[](const Key &) const { 128 Value operator[](const Key &) const { 129 129 return *static_cast<Value *>(0); 130 130 } … … 135 135 template<typename _ReadWriteMap> 136 136 struct Constraints { 137 138 139 140 137 void constraints() { 138 checkConcept<ReadMap<K, T>, _ReadWriteMap >(); 139 checkConcept<WriteMap<K, T>, _ReadWriteMap >(); 140 } 141 141 }; 142 142 }; … … 165 165 166 166 /// Returns a reference to the value associated with the given key. 167 Reference operator[](const Key &) { 167 Reference operator[](const Key &) { 168 168 return *static_cast<Value *>(0); 169 169 } … … 179 179 template<typename _ReferenceMap> 180 180 struct Constraints { 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 181 void constraints() { 182 checkConcept<ReadWriteMap<K, T>, _ReferenceMap >(); 183 ref = m[key]; 184 m[key] = val; 185 m[key] = ref; 186 m[key] = cref; 187 own_ref = m[own_key]; 188 m[own_key] = own_val; 189 m[own_key] = own_ref; 190 m[own_key] = own_cref; 191 m[key] = m[own_key]; 192 m[own_key] = m[key]; 193 } 194 const Key& key; 195 Value& val; 196 Reference ref; 197 ConstReference cref; 198 const typename _ReferenceMap::Key& own_key; 199 typename _ReferenceMap::Value& own_val; 200 typename _ReferenceMap::Reference own_ref; 201 typename _ReferenceMap::ConstReference own_cref; 202 _ReferenceMap& m; 203 203 }; 204 204 };
Note: See TracChangeset
for help on using the changeset viewer.