Ticket #3972: unordered_equal_range_dispatch.patch
File unordered_equal_range_dispatch.patch, 4.5 KB (added by , 13 years ago) |
---|
-
boost/pending/container_traits.hpp
1 // (C) Copyright Jeremy Siek 2004 1 // (C) Copyright Jeremy Siek 2004, 2010 2 2 // (C) Copyright Thomas Claveirole 2010 3 3 // Distributed under the Boost Software License, Version 1.0. (See 4 4 // accompanying file LICENSE_1_0.txt or copy at … … 263 263 264 264 // hash_set, hash_map 265 265 266 struct unordered_set_tag : 267 virtual public simple_associative_container_tag, 268 virtual public unique_associative_container_tag 269 { }; 270 271 struct unordered_multiset_tag : 272 virtual public simple_associative_container_tag, 273 virtual public multiple_associative_container_tag 274 { }; 275 276 277 struct unordered_map_tag : 278 virtual public pair_associative_container_tag, 279 virtual public unique_associative_container_tag 280 { }; 281 282 struct unordered_multimap_tag : 283 virtual public pair_associative_container_tag, 284 virtual public multiple_associative_container_tag 285 { }; 286 287 266 288 #ifndef BOOST_NO_HASH 267 289 #ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION 268 290 template <class Key, class Eq, class Hash, class Alloc> 269 291 struct container_traits< boost::unordered_set<Key,Eq,Hash,Alloc> > { 270 typedef set_tag category;292 typedef unordered_set_tag category; 271 293 typedef unstable_tag iterator_stability; 272 294 }; 273 295 template <class Key, class T, class Eq, class Hash, class Alloc> 274 296 struct container_traits< boost::unordered_map<Key,T,Eq,Hash,Alloc> > { 275 typedef map_tag category;297 typedef unordered_map_tag category; 276 298 typedef unstable_tag iterator_stability; 277 299 }; 278 300 template <class Key, class Eq, class Hash, class Alloc> 279 301 struct container_traits< boost::unordered_multiset<Key,Eq,Hash,Alloc> > { 280 typedef multiset_tag category;302 typedef unordered_multiset_tag category; 281 303 typedef unstable_tag iterator_stability; 282 304 }; 283 305 template <class Key, class T, class Eq, class Hash, class Alloc> 284 306 struct container_traits< boost::unordered_multimap<Key,T,Eq,Hash,Alloc> > { 285 typedef multimap_tag category;307 typedef unordered_multimap_tag category; 286 308 typedef unstable_tag iterator_stability; 287 309 }; 288 310 #endif 289 311 template <class Key, class Eq, class Hash, class Alloc> 290 set_tag container_category(const boost::unordered_set<Key,Eq,Hash,Alloc>&) 291 { return set_tag(); } 312 unordered_set_tag 313 container_category(const boost::unordered_set<Key,Eq,Hash,Alloc>&) 314 { return unordered_set_tag(); } 292 315 293 316 template <class Key, class T, class Eq, class Hash, class Alloc> 294 map_tag container_category(const boost::unordered_map<Key,T,Eq,Hash,Alloc>&) 295 { return map_tag(); } 317 unordered_map_tag 318 container_category(const boost::unordered_map<Key,T,Eq,Hash,Alloc>&) 319 { return unordered_map_tag(); } 296 320 297 321 template <class Key, class Eq, class Hash, class Alloc> 298 322 unstable_tag iterator_stability(const boost::unordered_set<Key,Eq,Hash,Alloc>&) … … 302 326 unstable_tag iterator_stability(const boost::unordered_map<Key,T,Eq,Hash,Alloc>&) 303 327 { return unstable_tag(); } 304 328 template <class Key, class Eq, class Hash, class Alloc> 305 multiset_tag329 unordered_multiset_tag 306 330 container_category(const boost::unordered_multiset<Key,Eq,Hash,Alloc>&) 307 { return multiset_tag(); }331 { return unordered_multiset_tag(); } 308 332 309 333 template <class Key, class T, class Eq, class Hash, class Alloc> 310 multimap_tag334 unordered_multimap_tag 311 335 container_category(const boost::unordered_multimap<Key,T,Eq,Hash,Alloc>&) 312 { return multimap_tag(); }336 { return unordered_multimap_tag(); } 313 337 314 338 template <class Key, class Eq, class Hash, class Alloc> 315 339 unstable_tag … … 435 459 436 460 // Equal range 437 461 template <class Container, 438 class LessThanComparable, 439 class ContainerCategory> 462 class LessThanComparable> 440 463 std::pair<typename Container::iterator, typename Container::iterator> 441 464 equal_range_dispatch(Container& c, 442 465 const LessThanComparable& value, 443 con st ContainerCategory&)466 container_tag) 444 467 { 445 468 // c must be sorted for std::equal_range to behave properly. 446 469 return std::equal_range(c.begin(), c.end(), value); … … 451 474 typename AssociativeContainer::iterator> 452 475 equal_range_dispatch(AssociativeContainer& c, 453 476 const LessThanComparable& value, 454 const associative_container_tag&)477 associative_container_tag) 455 478 { 456 479 return c.equal_range(value); 457 480 }