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.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@214760 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user