[libcxx] r289204 - Fix missing const on set::count. Patch from Andrey Khalyavin

Eric Fiselier via cfe-commits cfe-commits at lists.llvm.org
Fri Dec 9 04:17:31 PST 2016


Author: ericwf
Date: Fri Dec  9 06:17:31 2016
New Revision: 289204

URL: http://llvm.org/viewvc/llvm-project?rev=289204&view=rev
Log:
Fix missing const on set::count. Patch from Andrey Khalyavin

Modified:
    libcxx/trunk/include/set
    libcxx/trunk/test/std/containers/associative/set/count.pass.cpp

Modified: libcxx/trunk/include/set
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/set?rev=289204&r1=289203&r2=289204&view=diff
==============================================================================
--- libcxx/trunk/include/set (original)
+++ libcxx/trunk/include/set Fri Dec  9 06:17:31 2016
@@ -672,7 +672,7 @@ public:
     template <typename _K2>
     _LIBCPP_INLINE_VISIBILITY
     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
     _LIBCPP_INLINE_VISIBILITY
     iterator lower_bound(const key_type& __k)

Modified: libcxx/trunk/test/std/containers/associative/set/count.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/associative/set/count.pass.cpp?rev=289204&r1=289203&r2=289204&view=diff
==============================================================================
--- libcxx/trunk/test/std/containers/associative/set/count.pass.cpp (original)
+++ libcxx/trunk/test/std/containers/associative/set/count.pass.cpp Fri Dec  9 06:17:31 2016
@@ -145,23 +145,25 @@ int main()
     m.insert ( V::make ( 11 ));
     m.insert ( V::make ( 12 ));
 
-    R r = m.count(5);
+    const M& mc = m;
+
+    R r = mc.count(5);
     assert(r == 1);
-    r = m.count(6);
+    r = mc.count(6);
     assert(r == 1);
-    r = m.count(7);
+    r = mc.count(7);
     assert(r == 1);
-    r = m.count(8);
+    r = mc.count(8);
     assert(r == 1);
-    r = m.count(9);
+    r = mc.count(9);
     assert(r == 1);
-    r = m.count(10);
+    r = mc.count(10);
     assert(r == 1);
-    r = m.count(11);
+    r = mc.count(11);
     assert(r == 1);
-    r = m.count(12);
+    r = mc.count(12);
     assert(r == 1);
-    r = m.count(4);
+    r = mc.count(4);
     assert(r == 0);
     }
 #endif




More information about the cfe-commits mailing list