diff options
author | Billy Robert O'Neal III <bion@microsoft.com> | 2018-01-05 01:31:52 +0000 |
---|---|---|
committer | Billy Robert O'Neal III <bion@microsoft.com> | 2018-01-05 01:31:52 +0000 |
commit | d432d89454eb2696e5758d9d8ca9e4227d461ed1 (patch) | |
tree | 73b8684977a8faef67c5cb59bd37d3e48faad75f /libcxx/test/std/numerics/numeric.ops | |
parent | 1ef4ef22362c5499966b97d6ae898fa589af20ac (diff) | |
download | bcm5719-llvm-d432d89454eb2696e5758d9d8ca9e4227d461ed1.tar.gz bcm5719-llvm-d432d89454eb2696e5758d9d8ca9e4227d461ed1.zip |
Add move-only types test to transform_reduce iter iter iter init op op.
llvm-svn: 321849
Diffstat (limited to 'libcxx/test/std/numerics/numeric.ops')
-rw-r--r-- | libcxx/test/std/numerics/numeric.ops/transform.reduce/transform_reduce_iter_iter_iter_init_op_op.pass.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/libcxx/test/std/numerics/numeric.ops/transform.reduce/transform_reduce_iter_iter_iter_init_op_op.pass.cpp b/libcxx/test/std/numerics/numeric.ops/transform.reduce/transform_reduce_iter_iter_iter_init_op_op.pass.cpp index 41ea3b38a7f..f60a0f149bc 100644 --- a/libcxx/test/std/numerics/numeric.ops/transform.reduce/transform_reduce_iter_iter_iter_init_op_op.pass.cpp +++ b/libcxx/test/std/numerics/numeric.ops/transform.reduce/transform_reduce_iter_iter_iter_init_op_op.pass.cpp @@ -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(); } |