2011-08-25 20 views
8

Ben iç içe geçmiş bir sınıf şablonu için yöntem beyanı ile ilgili bir sorun yaşıyorum. AşağıdakiC++ İçiçe Şablon Sınıf Yöntemi Sayı

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 
} 

sorunsuz iş gibi görünüyor: Böyle bir şey var Ancak

template <typename T> 
template <typename Y> 
HashTrie<T>::Entry<Y> HashTrie<T>::Entry<Y>::someMethod() { 
    //... 
} 

bu değil: Ben GCC aşağıdaki hatayı alıyorum

template <typename T> 
template <typename U> 
std::map<char, HashTrie<T>::Node<U> > HashTrie<T>::Node<U>::anotherMethod() { 
// ... 
} 

./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 

Bir TypeName ekleyerek çalıştı, ama bu içinde ...

./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

template <typename T> 
template <typename U> 
std::map<char, typename HashTrie<T>::Node<U> > HashTrie<T>::Node<U>::anotherMethod() { 
// ... 
} 

sonuçlarını yardımcı görünmüyor diyor ki:

./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() { 

gerçekten emin değilim burada ne yapmak ve web üzerindeki herhangi benzer sorunları bulmak zor bir zaman vardı için. Herhangi bir yardım takdir edilecektir.

cevap

7

bu Say:

template <typename T> 
template <typename U> 
std::map<char, typename HashTrie<T>::template Node<U> > HashTrie<T>::Node<U>::foo() 
{ 
} 
+0

Çok teşekkür ederim! – Dan