Как правильно заполнить итератор **random_access_iterator** для класса?
Помогите мне пожалуйста заполнить правильно итератор random_access_iterator для моего класса. p_str это char * p_str
/* Класс string только для строк char или wchar_t */
template<class T = char>
class string
{static_assert(std::is_same_v<T,char> || std::is_same_v<T,wchar_t>, " Err Type ");
/* Итератор */
//------------------------------------------------------------------
private:
template<class T>
class string_iterator
{
public:
using value_type = T;
using iterator_category = std::random_access_iterator_tag;
using difference_type = ptrdiff_t;
using pointer = T*;
using reference = T&;
string_iterator() noexcept = default;
explicit string_iterator(T *curr) noexcept : current(curr){}
string_iterator& operator = ( const string_iterator &other)
{
if (this != &other)
{
current = other.current;
}
return *this;
}
string_iterator &operator ++()
{
++current;
return *this;
}
string_iterator operator ++(int i)
{
string_iterator tmp(current);
++current;
return tmp;
}
string_iterator &operator --()
{
--current;
return *this;
}
string_iterator operator --(int i)
{
string_iterator tmp(current);
--current;
return tmp;
}
// Операции, необходимые для RandomAccessIterator.
reference operator[](difference_type n) const { auto tmp = *this; tmp += n; return *tmp; }
string_iterator& operator+=(difference_type n) { /* что тут */return *this; }
string_iterator& operator-=(difference_type n) { return *this += -n; }
reference operator *() const noexcept { return *current; }
pointer operator ->() const noexcept { return current; }
bool operator == (const string_iterator &other )
{
return current == other.current;
}
bool operator != ( const string_iterator &other )
{
return !( *this == other );
}
private:
pointer current{0};
};
//------------------------------------------------------------------
public:
using iterator = string_iterator<T>;
using const_iterator = string_iterator<const T>;
using size_type = size_t;
using pointer = T *;
using const_pointer = const T *;
using reference = T &;
using const_reference = const T &;
using value_type = T;
iterator begin() noexcept { assert(p_str); return iterator(p_str); }
iterator end() noexcept { assert(p_str); return iterator(p_str + leng); }
const_iterator cbegin() const noexcept { return const_iterator(p_str); }
const_iterator cend() const noexcept { return const_iterator(p_str + leng); }
iterator rbegin() noexcept { assert(p_str); return iterator(p_str + leng); }
iterator rend() noexcept { assert(p_str); return iterator(p_str); }
const_iterator crbegin() const noexcept {return const_iterator(p_str + leng);}
const_iterator crend() const noexcept {return const_iterator(p_str);}
//------------------------------------------------------------------
private: