Reputation: 103
In a tree template class, a ConstIterator is being defined from an Iterator in the following way:
template <typename k_T, typename v_T>
class Tree<k_T, v_T>::ConstIterator : public Tree<k_T, v_T>::Iterator {
using parent = Tree<k_T, v_T>::Iterator;
public:
using parent::Iterator;
const std::pair<k_T, v_T>& operator*() const { return parent::operator*(); }
};
but it's not clear to me what the using parent::Iterator
is doing.
Upvotes: 0
Views: 33
Reputation: 19118
It inherits the constructors of parent
.
If the using-declaration refers to a constructor of a direct base of the class being defined (e.g. using Base::Base;), constructors of that base class are inherited [...] The inherited constructors are equivalent to user-defined constructors with an empty body and with a member initializer list consisting of a single nested-name-specifier, which forwards all of its arguments to the base class constructor.
See Inheriting constructors: http://en.cppreference.com/w/cpp/language/using_declaration
Upvotes: 1