Add move-only types test to transform_reduce iter iter iter init op op.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@321849 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Billy Robert O'Neal III
2018-01-05 01:31:52 +00:00
parent 519485521a
commit 5de0f33bc6

View File

@@ -19,7 +19,9 @@
#include <numeric>
#include <cassert>
#include <iterator>
#include "MoveOnly.h"
#include "test_iterators.h"
template <class Iter1, class Iter2, class T, class Op1, class Op2>
@@ -58,6 +60,16 @@ void test_return_type()
decltype(std::transform_reduce(p, p, p, Init{}, std::plus<>(), std::multiplies<>()))> );
}
void test_move_only_types()
{
MoveOnly ia[] = {{1}, {2}, {3}};
MoveOnly ib[] = {{1}, {2}, {3}};
assert(14 ==
std::transform_reduce(std::begin(ia), std::end(ia), std::begin(ib), MoveOnly{0},
[](const MoveOnly& lhs, const MoveOnly& rhs) { return MoveOnly{lhs.get() + rhs.get()}; },
[](const MoveOnly& lhs, const MoveOnly& rhs) { return MoveOnly{lhs.get() * rhs.get()}; }).get());
}
int main()
{
test_return_type<char, int>();
@@ -94,4 +106,6 @@ int main()
test<const int*, unsigned int *>();
test< int*, const unsigned int *>();
test< int*, unsigned int *>();
test_move_only_types();
}