summaryrefslogtreecommitdiffstats
path: root/libcxx/test/utilities/function.objects
diff options
context:
space:
mode:
authorMarshall Clow <mclow.lists@gmail.com>2014-08-04 19:20:17 +0000
committerMarshall Clow <mclow.lists@gmail.com>2014-08-04 19:20:17 +0000
commit89872e99a51761419440e16c839f4e8b6b4e6fce (patch)
treef7e467ba15de4ebae33a92327cd9ab320c74ca99 /libcxx/test/utilities/function.objects
parentb4cb487c10ad04ad1330794687b2892602fa3bd3 (diff)
downloadbcm5719-llvm-89872e99a51761419440e16c839f4e8b6b4e6fce.tar.gz
bcm5719-llvm-89872e99a51761419440e16c839f4e8b6b4e6fce.zip
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
Diffstat (limited to 'libcxx/test/utilities/function.objects')
-rw-r--r--libcxx/test/utilities/function.objects/refwrap/refwrap.helpers/ref_2.pass.cpp18
1 files changed, 18 insertions, 0 deletions
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 1eb92aa42c2..5a95097f689 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 <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);
+ }
}
OpenPOWER on IntegriCloud