[Boost-bugs] [Boost C++ Libraries] #2484: Const-overload needed for bimap associative_container_adaptor::count()

Subject: [Boost-bugs] [Boost C++ Libraries] #2484: Const-overload needed for bimap associative_container_adaptor::count()
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2008-11-07 16:48:57


#2484: Const-overload needed for bimap associative_container_adaptor::count()
--------------------------------+-------------------------------------------
 Reporter: mlcreech_at_[hidden] | Owner: matias
     Type: Patches | Status: new
Milestone: Boost 1.38.0 | Component: bimap
  Version: Boost 1.36.0 | Severity: Problem
 Keywords: |
--------------------------------+-------------------------------------------
 Would it be possible to include a const-overloaded version of count() for
 associative containers in boost::bimaps? I had some code like this:

 {{{
 void CMyClass::func(size_t key) const {
        size_t num_elements=_member_map.count(key);
        ...
 }
 }}}

 where _member_map was a std::map, and it worked fine. When I changed
 _member_map to a bimap, the equivalent code:

 {{{
 void CMyClass::func(size_t key) const {
        size_t num_elements=_member_map.left.count(key);
        ...
 }
 }}}

 gives an error, because count() is non-const (whereas GCC's
 std::map::count() is const). That's presumably done because the STL
 documentation declares count() as non-const (not sure why), but it doesn't
 seem there would be any harm in adding a const-overload so that this kind
 of code would compile when the underlying type supports it. The attached
 patch fixes the problem for me.

 Thanks

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/2484>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:49:59 UTC