Fix missing const on set::count. Patch from Andrey Khalyavin

llvm-svn: 289204
This commit is contained in:
Eric Fiselier 2016-12-09 12:17:31 +00:00
parent 21d1032855
commit 41b4d6c8ff
2 changed files with 12 additions and 10 deletions

View File

@ -672,7 +672,7 @@ public:
template <typename _K2> template <typename _K2>
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
typename enable_if<__is_transparent<_Compare, _K2>::value,size_type>::type typename enable_if<__is_transparent<_Compare, _K2>::value,size_type>::type
count(const _K2& __k) {return __tree_.__count_unique(__k);} count(const _K2& __k) const {return __tree_.__count_unique(__k);}
#endif #endif
_LIBCPP_INLINE_VISIBILITY _LIBCPP_INLINE_VISIBILITY
iterator lower_bound(const key_type& __k) iterator lower_bound(const key_type& __k)

View File

@ -145,23 +145,25 @@ int main()
m.insert ( V::make ( 11 )); m.insert ( V::make ( 11 ));
m.insert ( V::make ( 12 )); m.insert ( V::make ( 12 ));
R r = m.count(5); const M& mc = m;
R r = mc.count(5);
assert(r == 1); assert(r == 1);
r = m.count(6); r = mc.count(6);
assert(r == 1); assert(r == 1);
r = m.count(7); r = mc.count(7);
assert(r == 1); assert(r == 1);
r = m.count(8); r = mc.count(8);
assert(r == 1); assert(r == 1);
r = m.count(9); r = mc.count(9);
assert(r == 1); assert(r == 1);
r = m.count(10); r = mc.count(10);
assert(r == 1); assert(r == 1);
r = m.count(11); r = mc.count(11);
assert(r == 1); assert(r == 1);
r = m.count(12); r = mc.count(12);
assert(r == 1); assert(r == 1);
r = m.count(4); r = mc.count(4);
assert(r == 0); assert(r == 0);
} }
#endif #endif