File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 77#include < thrust/sequence.h>
88#include < thrust/iterator/counting_iterator.h>
99
10+ #include < memory>
11+
1012template <class Vector >
1113void TestTransformIterator (void )
1214{
@@ -84,3 +86,28 @@ struct TestTransformIteratorReduce
8486};
8587VariableUnitTest<TestTransformIteratorReduce, IntegralTypes> TestTransformIteratorReduceInstance;
8688
89+
90+ struct ExtractValue {
91+ int operator ()(std::unique_ptr<int > const & n){
92+ return *n;
93+ }
94+ };
95+
96+ void TestTransformIteratorNonCopyable (){
97+
98+ thrust::host_vector<std::unique_ptr<int >> hv (4 );
99+ hv[0 ].reset (new int {1 });
100+ hv[1 ].reset (new int {2 });
101+ hv[2 ].reset (new int {3 });
102+ hv[3 ].reset (new int {4 });
103+
104+ auto transformed = thrust::make_transform_iterator (hv.begin (), ExtractValue{});
105+ ASSERT_EQUAL (transformed[0 ], 1 );
106+ ASSERT_EQUAL (transformed[1 ], 2 );
107+ ASSERT_EQUAL (transformed[2 ], 3 );
108+ ASSERT_EQUAL (transformed[3 ], 4 );
109+
110+ }
111+
112+ DECLARE_UNITTEST (TestTransformIteratorNonCopyable);
113+
You can’t perform that action at this time.
0 commit comments