8
ネストされたクラステンプレートのメソッド宣言に問題があります。 私はこのようなものがあります:C++ネストされたテンプレートクラスメソッドの問題
template <typename T>
class HashTrie
{
template <typename Y>
class Entry
{ // members and methods here
};
template <typename U>
class Node
{ // members and methods here
};
// members and methods here
}
次は、問題なく動作するようです:
template <typename T>
template <typename Y>
HashTrie<T>::Entry<Y> HashTrie<T>::Entry<Y>::someMethod() {
//...
}
しかし、これにはない:
template <typename T>
template <typename U>
std::map<char, HashTrie<T>::Node<U> > HashTrie<T>::Node<U>::anotherMethod() {
// ...
}
私はGCCに次のエラーを取得します
./HashTrie.h:389: error: type/value mismatch at argument 2 in template parameter list for ‘template<class _Key, class _Tp, class _Compare, class _Alloc> class std::map’
./HashTrie.h:389: error: expected a type, got ‘(HashTrie::Node < <expression error>)’
./HashTrie.h:389: error: template argument 4 is invalid
./HashTrie.h:389: error: expected unqualified-id before ‘>’ token
私は型名を追加しようとしたが、それはで...
template <typename T>
template <typename U>
std::map<char, typename HashTrie<T>::Node<U> > HashTrie<T>::Node<U>::anotherMethod() {
// ...
}
結果
./HashTrie.h:389: error: template argument 2 is invalid
./HashTrie.h:389: error: template argument 4 is invalid
./HashTrie.h:389: error: expected unqualified-id before ‘>’ token
を助けていないようですICPCは言う:
./HashTrie.h(389): error: template parameter "HashTrie<T>::Node [with T=T]" may not have a template argument list
std::map<char, typename HashTrie<T>::Node<U> > HashTrie<T>::Node<U>::newNodeMap() {
私は本当にわからないんだけど何をここでやるべきか、Web上で類似の問題を見つけるのは苦労しました。どんな助けもありがとう。
はありがとうございました! – Dan