Ticket #3972: unordered_equal_range_dispatch.patch

File unordered_equal_range_dispatch.patch, 4.5 KB (added by Ignacy Gawedzki <i@…>, 13 years ago)

Fix equal_range dispatch and container categories

  • boost/pending/container_traits.hpp

     
    1 //  (C) Copyright Jeremy Siek 2004 
     1//  (C) Copyright Jeremy Siek 2004, 2010
    22//  (C) Copyright Thomas Claveirole 2010
    33//  Distributed under the Boost Software License, Version 1.0. (See
    44//  accompanying file LICENSE_1_0.txt or copy at
     
    263263
    264264 // hash_set, hash_map
    265265
     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
    266288#ifndef BOOST_NO_HASH
    267289#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
    268290  template <class Key, class Eq, class Hash, class Alloc>
    269291  struct container_traits< boost::unordered_set<Key,Eq,Hash,Alloc> > {
    270     typedef set_tag category;
     292    typedef unordered_set_tag category;
    271293    typedef unstable_tag iterator_stability;
    272294  };
    273295  template <class Key, class T, class Eq, class Hash, class Alloc>
    274296  struct container_traits< boost::unordered_map<Key,T,Eq,Hash,Alloc> > {
    275     typedef map_tag category;
     297    typedef unordered_map_tag category;
    276298    typedef unstable_tag iterator_stability;
    277299  };
    278300  template <class Key, class Eq, class Hash, class Alloc>
    279301  struct container_traits< boost::unordered_multiset<Key,Eq,Hash,Alloc> > {
    280     typedef multiset_tag category;
     302    typedef unordered_multiset_tag category;
    281303    typedef unstable_tag iterator_stability;
    282304  };
    283305  template <class Key, class T, class Eq, class Hash, class Alloc>
    284306  struct container_traits< boost::unordered_multimap<Key,T,Eq,Hash,Alloc> > {
    285     typedef multimap_tag category;
     307    typedef unordered_multimap_tag category;
    286308    typedef unstable_tag iterator_stability;
    287309  };
    288310#endif
    289311  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(); }
    292315
    293316  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(); }
    296320
    297321  template <class Key, class Eq, class Hash, class Alloc>
    298322  unstable_tag iterator_stability(const boost::unordered_set<Key,Eq,Hash,Alloc>&)
     
    302326  unstable_tag iterator_stability(const boost::unordered_map<Key,T,Eq,Hash,Alloc>&)
    303327  { return unstable_tag(); }
    304328  template <class Key, class Eq, class Hash, class Alloc>
    305   multiset_tag
     329  unordered_multiset_tag
    306330  container_category(const boost::unordered_multiset<Key,Eq,Hash,Alloc>&)
    307   { return multiset_tag(); }
     331  { return unordered_multiset_tag(); }
    308332
    309333  template <class Key, class T, class Eq, class Hash, class Alloc>
    310   multimap_tag
     334  unordered_multimap_tag
    311335  container_category(const boost::unordered_multimap<Key,T,Eq,Hash,Alloc>&)
    312   { return multimap_tag(); }
     336  { return unordered_multimap_tag(); }
    313337
    314338  template <class Key, class Eq, class Hash, class Alloc>
    315339  unstable_tag
     
    435459
    436460  // Equal range
    437461  template <class Container,
    438             class LessThanComparable,
    439             class ContainerCategory>
     462            class LessThanComparable>
    440463  std::pair<typename Container::iterator, typename Container::iterator>
    441464  equal_range_dispatch(Container& c,
    442465                       const LessThanComparable& value,
    443                        const ContainerCategory&)
     466                       container_tag)
    444467  {
    445468    // c must be sorted for std::equal_range to behave properly.
    446469    return std::equal_range(c.begin(), c.end(), value);
     
    451474            typename AssociativeContainer::iterator>
    452475  equal_range_dispatch(AssociativeContainer& c,
    453476                       const LessThanComparable& value,
    454                        const associative_container_tag&)
     477                       associative_container_tag)
    455478  {
    456479    return c.equal_range(value);
    457480  }