| ... | ... |
@@ -46,25 +46,24 @@ |
| 46 | 46 |
/// The value type of the map. (The type of objects associated with the keys). |
| 47 | 47 |
typedef T Value; |
| 48 | 48 |
|
| 49 | 49 |
/// Returns the value associated with a key. |
| 50 | 50 |
|
| 51 | 51 |
/// Returns the value associated with a key. |
| 52 | 52 |
/// \bug Value shouldn't need to be default constructible. |
| 53 | 53 |
/// |
| 54 | 54 |
Value operator[](const Key &) const {return Value();}
|
| 55 | 55 |
|
| 56 | 56 |
template<typename _ReadMap> |
| 57 | 57 |
struct Constraints {
|
| 58 |
|
|
| 59 | 58 |
void constraints() {
|
| 60 | 59 |
Value val = m[key]; |
| 61 | 60 |
val = m[key]; |
| 62 | 61 |
typename _ReadMap::Value own_val = m[own_key]; |
| 63 | 62 |
own_val = m[own_key]; |
| 64 | 63 |
|
| 65 | 64 |
ignore_unused_variable_warning(val); |
| 66 | 65 |
ignore_unused_variable_warning(own_val); |
| 67 | 66 |
ignore_unused_variable_warning(key); |
| 68 | 67 |
} |
| 69 | 68 |
Key& key; |
| 70 | 69 |
typename _ReadMap::Key& own_key; |
| ... | ... |
@@ -166,43 +165,42 @@ |
| 166 | 165 |
protected: |
| 167 | 166 |
Value tmp; |
| 168 | 167 |
public: |
| 169 | 168 |
|
| 170 | 169 |
///Returns a reference to the value associated with a key. |
| 171 | 170 |
Reference operator[](const Key &) { return tmp; }
|
| 172 | 171 |
///Returns a const reference to the value associated with a key. |
| 173 | 172 |
ConstReference operator[](const Key &) const { return tmp; }
|
| 174 | 173 |
/// Sets the value associated with a key. |
| 175 | 174 |
void set(const Key &k,const Value &t) { operator[](k)=t; }
|
| 176 | 175 |
|
| 177 | 176 |
template<typename _ReferenceMap> |
| 178 |
struct ReferenceMapConcept {
|
|
| 179 |
|
|
| 177 |
struct Constraints {
|
|
| 180 | 178 |
void constraints() {
|
| 181 |
checkConcept<ReadWriteMap, _ReferenceMap >(); |
|
| 179 |
checkConcept<ReadWriteMap<K, T>, _ReferenceMap >(); |
|
| 182 | 180 |
m[key] = val; |
| 183 | 181 |
val = m[key]; |
| 184 | 182 |
m[key] = ref; |
| 185 | 183 |
ref = m[key]; |
| 186 | 184 |
m[own_key] = own_val; |
| 187 | 185 |
own_val = m[own_key]; |
| 188 | 186 |
m[own_key] = own_ref; |
| 189 | 187 |
own_ref = m[own_key]; |
| 190 | 188 |
} |
| 191 | 189 |
|
| 192 | 190 |
typename _ReferenceMap::Key& own_key; |
| 193 | 191 |
typename _ReferenceMap::Value& own_val; |
| 194 |
typename _ReferenceMap::Reference |
|
| 192 |
typename _ReferenceMap::Reference own_ref; |
|
| 195 | 193 |
Key& key; |
| 196 | 194 |
Value& val; |
| 197 |
Reference |
|
| 195 |
Reference ref; |
|
| 198 | 196 |
_ReferenceMap& m; |
| 199 | 197 |
}; |
| 200 | 198 |
}; |
| 201 | 199 |
|
| 202 | 200 |
// @} |
| 203 | 201 |
|
| 204 | 202 |
} //namespace concepts |
| 205 | 203 |
|
| 206 | 204 |
} //namespace lemon |
| 207 | 205 |
|
| 208 | 206 |
#endif // LEMON_CONCEPT_MAPS_H |
0 comments (0 inline)