Skip to content
This repository was archived by the owner on Mar 21, 2024. It is now read-only.

Fix default constructor of counting iterator #1514

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions testing/counting_iterator.cu
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@

THRUST_DISABLE_MSVC_POSSIBLE_LOSS_OF_DATA_WARNING_BEGIN

template <typename T>
void TestCountingDefaultConstructor(void)
{
thrust::counting_iterator<T> iter0;
ASSERT_EQUAL(*iter0, T{});
}
DECLARE_GENERIC_UNITTEST(TestCountingDefaultConstructor);

void TestCountingIteratorCopyConstructor(void)
{
thrust::counting_iterator<int> iter0(100);
Expand Down
6 changes: 3 additions & 3 deletions thrust/iterator/counting_iterator.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,11 @@ template<typename Incrementable,
/*! \endcond
*/

/*! Null constructor initializes this \p counting_iterator's \c Incrementable
* counter using its null constructor.
/*! Default constructor initializes this \p counting_iterator's counter to
* `Incrementable{}`.
*/
__host__ __device__
counting_iterator() {}
counting_iterator() : super_t(Incrementable{}) {}

/*! Copy constructor copies the value of another \p counting_iterator into a
* new \p counting_iterator.
Expand Down