Hey folks, I'm having some weird issues with the iterator implementation in my STL container. I've tried to create a templated class so I can specialise it for iterator and const_iterator on the container. This is (I hope) everything I need to show:
// Part of the IteratorTemplate class
template <typename PointerType>
class IteratorTemplate {
public:
using iterator_category = std::contiguous_iterator_tag;
using value_type = Gapvector::value_type;
using element_type = value_type;
using pointer = PointerType;
using reference = value_type&;
using difference_type = std::ptrdiff_t;
using gapvector_pointer = std::conditional<std::is_const_v<PointerType>, const Gapvector*, Gapvector*>::type;
gapvector_pointer gv;
PointerType ptr;
IteratorTemplate() = default;
IteratorTemplate(gapvector_pointer self, PointerType input_ptr): gv(self), ptr(input_ptr) {}
// iterator types
using iterator = IteratorTemplate<pointer>;
using const_iterator = IteratorTemplate<const_pointer>;
// iterator classes on the STL container
iterator begin() noexcept { return iterator(this, bufferStart); }
iterator end() noexcept { return iterator(this, bufferEnd); }
const_iterator begin() const noexcept { return const_iterator(this, bufferStart); }
const_iterator end() const noexcept { return const_iterator(this, bufferEnd); }
const_iterator cbegin() const noexcept { return const_iterator(this, bufferStart); }
const_iterator cend() const noexcept { return const_iterator(this, bufferEnd); }