I have the following class declaration:
template <typename T, size_t N>
class CircularBuffer {
public:
using iterator = typename std::array<T, N>::iterator;
...
private:
std::array<T, N> m_elements;
...
};
Without "typename" keyword in "using "iterator = typename std::array::iterator;" compiler issues an error:
error: need ‘typename’ before ‘std::array<_Tp, _Nm>::iterator’ because ‘std::array<_Tp, _Nm>’ is a dependent scope.
But the statement "using iterator = std::array::iterator;" compiles.
As I understand "using" keyword is used only (except "using namespace ...") for creating type aliases, then why is there the need for "typename" at all in the above examples? Thank you!