0
2
0
... | ... |
@@ -46,12 +46,11 @@ |
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 the given key. |
50 |
|
|
51 |
/// Returns the value associated with the given key. |
|
52 |
/// \bug Value shouldn't need to be default constructible. |
|
53 |
Value operator[](const Key &) const { return Value(); } |
|
50 |
Value operator[](const Key &) const { |
|
51 |
return *static_cast<Value *>(0); |
|
52 |
} |
|
54 | 53 |
|
55 | 54 |
template<typename _ReadMap> |
56 | 55 |
struct Constraints { |
57 | 56 |
void constraints() { |
... | ... |
@@ -125,9 +124,11 @@ |
125 | 124 |
/// The value type of the map. (The type of objects associated with the keys). |
126 | 125 |
typedef T Value; |
127 | 126 |
|
128 | 127 |
/// Returns the value associated with the given key. |
129 |
Value operator[](const Key &) const { |
|
128 |
Value operator[](const Key &) const { |
|
129 |
return *static_cast<Value *>(0); |
|
130 |
} |
|
130 | 131 |
|
131 | 132 |
/// Sets the value associated with the given key. |
132 | 133 |
void set(const Key &, const Value &) {} |
133 | 134 |
|
... | ... |
@@ -159,17 +160,19 @@ |
159 | 160 |
typedef R Reference; |
160 | 161 |
/// The const reference type of the map. |
161 | 162 |
typedef CR ConstReference; |
162 | 163 |
|
163 |
protected: |
|
164 |
Value tmp; |
|
165 | 164 |
public: |
166 | 165 |
|
167 | 166 |
/// Returns a reference to the value associated with the given key. |
168 |
Reference operator[](const Key &) { |
|
167 |
Reference operator[](const Key &) { |
|
168 |
return *static_cast<Value *>(0); |
|
169 |
} |
|
169 | 170 |
|
170 | 171 |
/// Returns a const reference to the value associated with the given key. |
171 |
ConstReference operator[](const Key &) const { |
|
172 |
ConstReference operator[](const Key &) const { |
|
173 |
return *static_cast<Value *>(0); |
|
174 |
} |
|
172 | 175 |
|
173 | 176 |
/// Sets the value associated with the given key. |
174 | 177 |
void set(const Key &k,const Value &t) { operator[](k)=t; } |
175 | 178 |
... | ... |
@@ -31,8 +31,14 @@ |
31 | 31 |
struct A {}; |
32 | 32 |
inline bool operator<(A, A) { return true; } |
33 | 33 |
struct B {}; |
34 | 34 |
|
35 |
class C { |
|
36 |
int x; |
|
37 |
public: |
|
38 |
C(int _x) : x(_x) {} |
|
39 |
}; |
|
40 |
|
|
35 | 41 |
class F { |
36 | 42 |
public: |
37 | 43 |
typedef A argument_type; |
38 | 44 |
typedef B result_type; |
... | ... |
@@ -57,11 +63,15 @@ |
57 | 63 |
int main() |
58 | 64 |
{ |
59 | 65 |
// Map concepts |
60 | 66 |
checkConcept<ReadMap<A,B>, ReadMap<A,B> >(); |
67 |
checkConcept<ReadMap<A,C>, ReadMap<A,C> >(); |
|
61 | 68 |
checkConcept<WriteMap<A,B>, WriteMap<A,B> >(); |
69 |
checkConcept<WriteMap<A,C>, WriteMap<A,C> >(); |
|
62 | 70 |
checkConcept<ReadWriteMap<A,B>, ReadWriteMap<A,B> >(); |
71 |
checkConcept<ReadWriteMap<A,C>, ReadWriteMap<A,C> >(); |
|
63 | 72 |
checkConcept<ReferenceMap<A,B,B&,const B&>, ReferenceMap<A,B,B&,const B&> >(); |
73 |
checkConcept<ReferenceMap<A,C,C&,const C&>, ReferenceMap<A,C,C&,const C&> >(); |
|
64 | 74 |
|
65 | 75 |
// NullMap |
66 | 76 |
{ |
67 | 77 |
checkConcept<ReadWriteMap<A,B>, NullMap<A,B> >(); |
0 comments (0 inline)