mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-03-05 00:48:08 +00:00
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
This commit is contained in:
parent
b4cb487c10
commit
89872e99a5
@ -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);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user