From 89872e99a51761419440e16c839f4e8b6b4e6fce Mon Sep 17 00:00:00 2001 From: Marshall Clow Date: Mon, 4 Aug 2014 19:20:17 +0000 Subject: [PATCH] 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. llvm-svn: 214760 --- libcxx/include/__functional_base_03 | 6 +++--- .../refwrap/refwrap.helpers/ref_2.pass.cpp | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/libcxx/include/__functional_base_03 b/libcxx/include/__functional_base_03 index f297ee057a9b..22c06add90f4 100644 --- a/libcxx/include/__functional_base_03 +++ b/libcxx/include/__functional_base_03 @@ -1027,7 +1027,7 @@ public: typename __invoke_return0::type operator() (_A0& __a0) const { - return __invoke(get(), __a0); + return __invoke(get(), __a0); } template @@ -1035,7 +1035,7 @@ public: typename __invoke_return1::type operator() (_A0& __a0, _A1& __a1) const { - return __invoke(get(), __a0, __a1); + return __invoke(get(), __a0, __a1); } template @@ -1043,7 +1043,7 @@ public: typename __invoke_return2::type operator() (_A0& __a0, _A1& __a1, _A2& __a2) const { - return __invoke(get(), __a0, __a1, __a2); + return __invoke(get(), __a0, __a1, __a2); } }; diff --git a/libcxx/test/utilities/function.objects/refwrap/refwrap.helpers/ref_2.pass.cpp b/libcxx/test/utilities/function.objects/refwrap/refwrap.helpers/ref_2.pass.cpp index 1eb92aa42c21..5a95097f689e 100644 --- a/libcxx/test/utilities/function.objects/refwrap/refwrap.helpers/ref_2.pass.cpp +++ b/libcxx/test/utilities/function.objects/refwrap/refwrap.helpers/ref_2.pass.cpp @@ -16,10 +16,28 @@ #include #include +#include "counting_predicates.hpp" + +bool is5 ( int i ) { return i == 5; } + +template +bool call_pred ( T pred ) { return pred(5); } + int main() { + { int i = 0; std::reference_wrapper r1 = std::ref(i); std::reference_wrapper r2 = std::ref(r1); assert(&r2.get() == &i); + } + { + unary_counting_predicate 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); + } }