summaryrefslogtreecommitdiffstats
path: root/libcxx/test/std/numerics
diff options
context:
space:
mode:
authorBilly Robert O'Neal III <bion@microsoft.com>2018-01-05 01:31:50 +0000
committerBilly Robert O'Neal III <bion@microsoft.com>2018-01-05 01:31:50 +0000
commit1ef4ef22362c5499966b97d6ae898fa589af20ac (patch)
treebe1553cb708ac44b30104b70b0a3b6be36636947 /libcxx/test/std/numerics
parent61d97da4f417b3a9d94b8ea0939e414d177ff2df (diff)
downloadbcm5719-llvm-1ef4ef22362c5499966b97d6ae898fa589af20ac.tar.gz
bcm5719-llvm-1ef4ef22362c5499966b97d6ae898fa589af20ac.zip
Add move-only types test for transform_reduce bop/uop.
llvm-svn: 321848
Diffstat (limited to 'libcxx/test/std/numerics')
-rw-r--r--libcxx/test/std/numerics/numeric.ops/transform.reduce/transform_reduce_iter_iter_init_bop_uop.pass.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/libcxx/test/std/numerics/numeric.ops/transform.reduce/transform_reduce_iter_iter_init_bop_uop.pass.cpp b/libcxx/test/std/numerics/numeric.ops/transform.reduce/transform_reduce_iter_iter_init_bop_uop.pass.cpp
index 98c58f99472..c5bcaf148ea 100644
--- a/libcxx/test/std/numerics/numeric.ops/transform.reduce/transform_reduce_iter_iter_init_bop_uop.pass.cpp
+++ b/libcxx/test/std/numerics/numeric.ops/transform.reduce/transform_reduce_iter_iter_init_bop_uop.pass.cpp
@@ -19,7 +19,9 @@
#include <numeric>
#include <cassert>
#include <utility>
+#include <iterator>
+#include "MoveOnly.h"
#include "test_iterators.h"
struct identity
@@ -81,6 +83,15 @@ void test_return_type()
decltype(std::transform_reduce(p, p, Init{}, std::plus<>(), identity()))> );
}
+void test_move_only_types()
+{
+ MoveOnly ia[] = {{1}, {2}, {3}};
+ assert(60 ==
+ std::transform_reduce(std::begin(ia), std::end(ia), MoveOnly{0},
+ [](const MoveOnly& lhs, const MoveOnly& rhs) { return MoveOnly{lhs.get() + rhs.get()}; },
+ [](const MoveOnly& target) { return MoveOnly{target.get() * 10}; }).get());
+}
+
int main()
{
test_return_type<char, int>();
@@ -105,4 +116,6 @@ int main()
unsigned res = std::transform_reduce(v.begin(), v.end(), 1U, std::multiplies<>(), twice());
assert(res == 46080); // 6! * 64 will not fit into a char
}
+
+ test_move_only_types();
}
OpenPOWER on IntegriCloud