I'm creating an Ordered Linked List derived from a Linked List base class, where both are templated. I know because of the Two-Phase name lookup I gotta specify that the variables depends on something, like "this->head", "LinkedList::head" or specify "using LinkedList::head" at the beginning. I prefer using the third one, but when there are a lot of members that are gonna be inherited, it becomes hella verbous. Is there some way to avoid this?
// Here I have the Base Class
template <typename T>
class LinkedList
{
...
public:
...
template <typename TArg> void push_front(TArg&& v0);
template <typename TArg> void push_back(TArg&& v0);
void pop_front();
void pop_back();
void erase(const LinkedList<T>::Iterator& pos);
void clear();
...
protected:
Node<T>* head;
Node<T>* last;
size_t _size;
LinkedList<T>::Iterator _begin;
LinkedList<T>::Iterator _end;
};
And the derived class
// Here I have the derived class
template <typename T>
class OrderedList : public LinkedList<T>
{
using LinkedList<T>::head;
using LinkedList<T>::last;
using LinkedList<T>::_size;
using LinkedList<T>::_begin;
using LinkedList<T>::_end;
using LinkedList<T>::push_back;
using LinkedList<T>::push_front;
using LinkedList<T>::clear;
...
...
public:
...
};
What can I do to deal with that?
Aucun commentaire:
Enregistrer un commentaire