[libcxx] r214760 - Fix a problem with reference_wrapper in C++03 that was causing counting predicates to fail. Add a test to make sure it works. However, most of the reference_wrapper tests still fail in C++03 mode, due to a lack of decltype. No change there.
Marshall Clow
mclow.lists at gmail.com
Mon Aug 4 12:20:17 PDT 2014
Author: marshall
Date: Mon Aug 4 14:20:17 2014
New Revision: 214760
URL: http://llvm.org/viewvc/llvm-project?rev=214760&view=rev
Log:
Fix a problem with reference_wrapper in C++03 that was causing counting predicates to fail. Add a test to make sure it works. However, most of the reference_wrapper tests still fail in C++03 mode, due to a lack of decltype. No change there.
Modified:
libcxx/trunk/include/__functional_base_03
libcxx/trunk/test/utilities/function.objects/refwrap/refwrap.helpers/ref_2.pass.cpp
Modified: libcxx/trunk/include/__functional_base_03
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__functional_base_03?rev=214760&r1=214759&r2=214760&view=diff
==============================================================================
--- libcxx/trunk/include/__functional_base_03 (original)
+++ libcxx/trunk/include/__functional_base_03 Mon Aug 4 14:20:17 2014
@@ -1027,7 +1027,7 @@ public:
typename __invoke_return0<type&, _A0>::type
operator() (_A0& __a0) const
{
- return __invoke(get(), __a0);
+ return __invoke<type&, _A0>(get(), __a0);
}
template <class _A0, class _A1>
@@ -1035,7 +1035,7 @@ public:
typename __invoke_return1<type&, _A0, _A1>::type
operator() (_A0& __a0, _A1& __a1) const
{
- return __invoke(get(), __a0, __a1);
+ return __invoke<type&, _A0, _A1>(get(), __a0, __a1);
}
template <class _A0, class _A1, class _A2>
@@ -1043,7 +1043,7 @@ public:
typename __invoke_return2<type&, _A0, _A1, _A2>::type
operator() (_A0& __a0, _A1& __a1, _A2& __a2) const
{
- return __invoke(get(), __a0, __a1, __a2);
+ return __invoke<type&, _A0, _A1, _A2>(get(), __a0, __a1, __a2);
}
};
Modified: libcxx/trunk/test/utilities/function.objects/refwrap/refwrap.helpers/ref_2.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/function.objects/refwrap/refwrap.helpers/ref_2.pass.cpp?rev=214760&r1=214759&r2=214760&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/function.objects/refwrap/refwrap.helpers/ref_2.pass.cpp (original)
+++ libcxx/trunk/test/utilities/function.objects/refwrap/refwrap.helpers/ref_2.pass.cpp Mon Aug 4 14:20:17 2014
@@ -16,10 +16,28 @@
#include <functional>
#include <cassert>
+#include "counting_predicates.hpp"
+
+bool is5 ( int i ) { return i == 5; }
+
+template <typename T>
+bool call_pred ( T pred ) { return pred(5); }
+
int main()
{
+ {
int i = 0;
std::reference_wrapper<int> r1 = std::ref(i);
std::reference_wrapper<int> r2 = std::ref(r1);
assert(&r2.get() == &i);
+ }
+ {
+ unary_counting_predicate<bool(*)(int), int> cp(is5);
+ assert(!cp(6));
+ assert(cp.count() == 1);
+ assert(call_pred(cp));
+ assert(cp.count() == 1);
+ assert(call_pred(std::ref(cp)));
+ assert(cp.count() == 2);
+ }
}
More information about the cfe-commits
mailing list