I'm currently refactoring some code using the C++11 Alias Template (aka. template<class A> using B = C<A>;
), but clang complains when I try to use the alias to implement a constructor or an operator.
Relevant header file:
template<class C>
class CSTree {
public:
class DepthIterator : public std::iterator<std::random_access_iterator_tag, C> {
DepthIterator(const DepthIterator&);
bool operator==(const DepthIterator&);
//other members omitted
}
//other members omitted
}
Relevant source file:
template<class C>
using DeIt = typename CSTree<C>::DepthIterator;
template<class C>
DeIt<C>::DepthIterator(const DepthIterator &rhs) { //Error here!
//...
}
template<class C>
bool DeIt<C>::operator== (const DepthIterator &rhs) { //Error here!
//...
}
Compiling with clang gives the following error:
src/CSTree.cpp:13:10: error: nested name specifier 'DeIt<C>::' for declaration does not refer into a class, class template or class template partial specialization
src/CSTree.cpp:18:15: error: nested name specifier 'DeIt<C>::' for declaration does not refer into a class, class template or class template partial specialization
My tries to search the internet did not lead to any clear material on this topic, so I'm wondering whether it is possible to implement operators and constructors on Alias Templates and if it is, any hint regarding where I am erring is greatly appreciated (I'm still pretty new to C++, so it might just be a really obnoxious mistake. In that case I beg your pardon in advance).