2
因此,我有SkipList.hpp,它有一個名爲SkipListIterator的嵌套模板類。在模板類中使用模板化嵌套類的Typedef
//SkipList.hpp
template <class Key_t, class Mapped_t>
class SkipList {
template <bool isConst, bool isReverse>
class SkipListIterator {
...
}
...
}
在我的Map.hpp中,我想爲不同類型的迭代器進行typedef。我試圖做的是以下幾點:
//Map.hpp
#include "SkipList.hpp"
template <class Key_t, class Mapped_t>
class Map {
typedef typename SkipList<Key_t, Mapped_t>::SkipListIterator<false, false> iterator;
typedef typename SkipList<Key_t, Mapped_t>::SkipListIterator<true, false> const_iterator;
typedef typename SkipList<Key_t, Mapped_t>::SkipListIterator<false, true> reverse_iterator;
typedef typename SkipList<Key_t, Mapped_t>::SkipListIterator<true, true> const_reverse_iterator;
...
}
這不起作用,和g ++給了我以下錯誤:
error: non-template 'SkipListIterator' used as template
typedef typename SkipList<Key_t, Mapped_t>::SkipListIterator<false, false> iterator
^
感謝您的快速答案,完美工作! – Adam