[libcxx] r321849 - Add move-only types test to transform_reduce iter iter iter init op op.

Billy Robert O'Neal III via cfe-commits cfe-commits at lists.llvm.org
Thu Jan 4 17:31:52 PST 2018


Author: bion
Date: Thu Jan  4 17:31:52 2018
New Revision: 321849

URL: http://llvm.org/viewvc/llvm-project?rev=321849&view=rev
Log:
Add move-only types test to transform_reduce iter iter iter init op op.

Modified:
    libcxx/trunk/test/std/numerics/numeric.ops/transform.reduce/transform_reduce_iter_iter_iter_init_op_op.pass.cpp

Modified: libcxx/trunk/test/std/numerics/numeric.ops/transform.reduce/transform_reduce_iter_iter_iter_init_op_op.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numeric.ops/transform.reduce/transform_reduce_iter_iter_iter_init_op_op.pass.cpp?rev=321849&r1=321848&r2=321849&view=diff
==============================================================================
--- libcxx/trunk/test/std/numerics/numeric.ops/transform.reduce/transform_reduce_iter_iter_iter_init_op_op.pass.cpp (original)
+++ libcxx/trunk/test/std/numerics/numeric.ops/transform.reduce/transform_reduce_iter_iter_iter_init_op_op.pass.cpp Thu Jan  4 17:31:52 2018
@@ -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();
 }




More information about the cfe-commits mailing list