gravatar
kpeter (Peter Kovacs)
kpeter@inf.elte.hu
More exact concept checking for map concepts.
0 1 0
default
1 file changed with 34 insertions and 31 deletions:
↑ Collapse diff ↑
Show white space 2 line context
... ...
@@ -48,7 +48,6 @@
48 48

	
49
      /// Returns the value associated with a key.
49
      /// Returns the value associated with the given key.
50 50

	
51
      /// Returns the value associated with a key.
51
      /// Returns the value associated with the given key.
52 52
      /// \bug Value shouldn't need to be default constructible.
53
      ///
54 53
      Value operator[](const Key &) const {return Value();}
... ...
@@ -63,9 +62,10 @@
63 62

	
63
	  ignore_unused_variable_warning(key);
64 64
	  ignore_unused_variable_warning(val);
65
	  ignore_unused_variable_warning(own_key);
65 66
	  ignore_unused_variable_warning(own_val);
66
	  ignore_unused_variable_warning(key);
67 67
	}
68
	Key& key;
69
	typename _ReadMap::Key& own_key;
70
	_ReadMap& m;
68
	const Key& key;
69
	const typename _ReadMap::Key& own_key;
70
	const _ReadMap& m;
71 71
      };
... ...
@@ -88,6 +88,6 @@
88 88

	
89
      /// Sets the value associated with a key.
89
      /// Sets the value associated with the given key.
90 90
      void set(const Key &,const Value &) {}
91 91

	
92
      ///Default constructor
92
      /// Default constructor.
93 93
      WriteMap() {}
... ...
@@ -97,5 +97,5 @@
97 97
	void constraints() {
98
	  // No constraints for constructor.
99 98
	  m.set(key, val);
100 99
	  m.set(own_key, own_val);
100

	
101 101
	  ignore_unused_variable_warning(key);
... ...
@@ -105,9 +105,7 @@
105 105
	}
106

	
107
	Value& val;
108
	typename _WriteMap::Value own_val;
109
	Key& key;
110
	typename _WriteMap::Key& own_key;
106
	const Key& key;
107
	const Value& val;
108
	const typename _WriteMap::Key& own_key;
109
	const typename _WriteMap::Value own_val;
111 110
	_WriteMap& m;
112

	
113 111
      };
... ...
@@ -129,5 +127,6 @@
129 127

	
130
      /// Returns the value associated with a key.
128
      /// Returns the value associated with the given key.
131 129
      Value operator[](const Key &) const {return Value();}
132
      /// Sets the value associated with a key.
130

	
131
      /// Sets the value associated with the given key.
133 132
      void set(const Key & ,const Value &) {}
... ...
@@ -148,3 +147,2 @@
148 147
    ///
149
    /// \todo Rethink this concept.
150 148
    template<typename K, typename T, typename R, typename CR>
... ...
@@ -168,7 +166,9 @@
168 166

	
169
      ///Returns a reference to the value associated with a key.
167
      /// Returns a reference to the value associated with the given key.
170 168
      Reference operator[](const Key &) { return tmp; }
171
      ///Returns a const reference to the value associated with a key.
169

	
170
      /// Returns a const reference to the value associated with the given key.
172 171
      ConstReference operator[](const Key &) const { return tmp; }
173
      /// Sets the value associated with a key.
172

	
173
      /// Sets the value associated with the given key.
174 174
      void set(const Key &k,const Value &t) { operator[](k)=t; }
... ...
@@ -179,18 +179,21 @@
179 179
	  checkConcept<ReadWriteMap<K, T>, _ReferenceMap >();
180
	  ref = m[key];
180 181
	  m[key] = val;
181
	  val  = m[key];
182 182
	  m[key] = ref;
183
	  ref = m[key];
183
	  m[key] = cref;
184
	  own_ref = m[own_key];
184 185
	  m[own_key] = own_val;
185
	  own_val  = m[own_key];
186 186
	  m[own_key] = own_ref;
187
	  own_ref = m[own_key];	  	  
187
	  m[own_key] = own_cref;
188
	  m[key] = m[own_key];
189
	  m[own_key] = m[key];
188 190
	}
189

	
190
	typename _ReferenceMap::Key& own_key;
191
	const Key& key;
192
	Value& val;
193
	Reference ref;
194
	ConstReference cref;
195
	const typename _ReferenceMap::Key& own_key;
191 196
	typename _ReferenceMap::Value& own_val;
192 197
	typename _ReferenceMap::Reference own_ref;
193
	Key& key;
194
	Value& val;
195
	Reference ref;
198
	typename _ReferenceMap::ConstReference own_cref;
196 199
	_ReferenceMap& m;
0 comments (0 inline)