I have a syntactic question rather,
With the following iterator class inside of a vector class,
#include <memory>
#include <cstddef>
#include <iterator>
namespace ft { template <class T, class Alloc = std::allocator<T> > class vector; }
template <class T, class Alloc>
class ft::vector
{
public:
typedef T value_type;
typedef typename allocator_type::reference reference;
typedef typename allocator_type::pointer pointer;
typedef ptrdiff_t difference_type;
template <class value_type>
class ptr_iterator : public std::iterator<std::random_access_iterator_tag, value_type>
{
public:
ptr_iterator();
};
typedef ptr_iterator<value_type> iterator;
typedef ptr_iterator<const value_type> const_iterator;
};
How can I address the constructor of ptr_iterator outside of the declaration?
I tried this way:
template <class T, class Alloc>
ft::vector<T, Alloc>::iterator::iterator() {}
But it yields
Vector.hpp:120:1: error: specializing member 'ft::vector<T, Alloc>::ptr_iterator<T>::iterator' requires 'template<>' syntax
ft::vector<T, Alloc>::iterator::iterator() {}
I attempted adding <> after both of the iterator words and replacing the second iterator word with ptr_iterator, but it still doesn't compile.
Can I still use the typedef without repeating both templates above the function signature?
Or is there a better design for the iterator declaration that'll allow me to define both iterator and const_iterator?