Changeset 946:c94ef40a22ce in lemon0.x for src/lemon/skeletons/maps.h
 Timestamp:
 10/28/04 00:38:50 (16 years ago)
 Branch:
 default
 Phase:
 public
 Convert:
 svn:c9d7d8f590d60310b91f818b3a526b0e/lemon/trunk@1322
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

src/lemon/skeletons/maps.h
r921 r946 17 17 #ifndef LEMON_MAPSKELETON_H 18 18 #define LEMON_MAPSKELETON_H 19 20 #include <lemon/concept_check.h> 19 21 20 22 ///\ingroup skeletons … … 114 116 }; 115 117 118 119 template<typename Item, typename T, typename Graph> 120 class GraphMap : public ReadWriteMap<Item, T> { 121 // I really, really don't like the idea that every graph should have 122 // reference maps! klao 123 124 private: 125 // We state explicitly that graph maps have no default constructor? 126 GraphMap(); 127 128 public: 129 explicit GraphMap(Graph const&) {} 130 // value for initializing 131 GraphMap(Graph const&, T) {} 132 133 // this probably should be required: 134 GraphMap(GraphMap const&) {} 135 GraphMap& operator=(GraphMap const&) { return *this; } 136 137 // but this is a absolute noop! We should provide a more generic 138 // graphmapcopy operation. 139 // 140 // template<typename TT> 141 // GraphMap(GraphMap<TT> const&); 142 // 143 // template<typename TT> 144 // GraphMap& operator=(const GraphMap<TT>&); 145 }; 146 147 148 /**************** Conceptchecking classes ****************/ 149 150 template<typename ReadMap> 151 struct ReadMapConcept { 152 typedef typename ReadMap::KeyType KeyType; 153 typedef typename ReadMap::ValueType ValueType; 154 155 void constraints() { 156 // No constraints for constructor. 157 158 // What are the requirement for the ValueType? 159 // CopyConstructible? Assignable? None of these? 160 ValueType v = m[k]; 161 v = m[k]; 162 163 // FIXME: 164 ignore_unused_variable_warning(v); 165 } 166 167 ReadMap m; 168 KeyType k; 169 }; 170 171 template<typename WriteMap> 172 struct WriteMapConcept { 173 typedef typename WriteMap::KeyType KeyType; 174 typedef typename WriteMap::ValueType ValueType; 175 176 void constraints() { 177 // No constraints for constructor. 178 179 m.set(k, v); 180 } 181 182 WriteMap m; 183 KeyType k; 184 ValueType v; 185 }; 186 187 template<typename ReadWriteMap> 188 struct ReadWriteMapConcept { 189 void constraints() { 190 function_requires< ReadMapConcept<ReadWriteMap> >(); 191 function_requires< WriteMapConcept<ReadWriteMap> >(); 192 } 193 }; 194 195 template<typename ReferenceMap> 196 struct ReferenceMapConcept { 197 typedef typename ReferenceMap::KeyType KeyType; 198 typedef typename ReferenceMap::ValueType ValueType; 199 typedef typename ReferenceMap::ReferenceType ReferenceType; 200 201 // What for is this? 202 typedef typename ReferenceMap::ConstReferenceType ConstReferenceType; 203 204 void constraints() { 205 function_requires< ReadWriteMapConcept<ReferenceMap> >(); 206 207 m[k] = v; 208 // Or should we require real reference? 209 // Like this: 210 // ValueType &vv = m[k]; 211 // ignore_unused_variable_warning(vv); 212 } 213 214 ReferenceMap m; 215 KeyType k; 216 ValueType v; 217 }; 218 219 /// \todo GraphMapConceptCheck 220 221 template<typename GraphMap, typename Graph> 222 struct GraphMapConcept { 223 void constraints() { 224 function_requires< ReadWriteMapConcept<GraphMap> >(); 225 // Construction with a graph parameter 226 GraphMap a(g); 227 // Ctor with a graph and a default value parameter 228 GraphMap a2(g,t); 229 // Copy ctor. Do we need it? 230 GraphMap b=c; 231 // Copy operator. Do we need it? 232 a=b; 233 234 ignore_unused_variable_warning(a2); 235 } 236 const GraphMap &c; 237 const Graph &g; 238 const typename GraphMap::ValueType &t; 239 }; 240 241 116 242 // @} 117 243
Note: See TracChangeset
for help on using the changeset viewer.