Skip to content

Commit 3f41835

Browse files
committed
Add explicit an constructor to non-const iterator
This will hopefully fix GCC and MSVC errors.
1 parent bbc0884 commit 3f41835

1 file changed

Lines changed: 13 additions & 5 deletions

File tree

include/LockFreeSpscQueue.h

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -269,11 +269,19 @@ class LockFreeSpscQueue
269269
class iterator : public const_iterator
270270
{
271271
public:
272-
using value_type = T;
273-
using pointer = T*;
274-
using reference = T&;
275-
276-
using const_iterator::const_iterator; // Inherit constructors
272+
using value_type = T;
273+
using pointer = T*;
274+
using reference = T&;
275+
using SpanIterator = typename std::span<T>::iterator;
276+
277+
// Provide an explicit constructor that takes mutable iterators.
278+
// This constructor correctly delegates to the const_iterator's base
279+
// constructor, allowing the valid conversion from iterator-to-T
280+
// to iterator-to-const-T to happen.
281+
iterator(SpanIterator b1_begin, SpanIterator b1_end,
282+
SpanIterator b2_begin, SpanIterator b2_end,
283+
bool is_begin)
284+
: const_iterator(b1_begin, b1_end, b2_begin, b2_end, is_begin) {}
277285

278286
reference operator*() const {
279287
return const_cast<reference>(const_iterator::operator*());

0 commit comments

Comments
 (0)