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