2014-01-27 67 views
3

我有一個嵌套模板類的問題。代碼編譯中VS2012罰款,但在VS2013和gcc 4.2.x版失敗:如何解決編譯錯誤:用作模板的非模板'iterator1'

#include <string> 

namespace utf { 
    class klar{ //my test class 
    public: 
     template <typename octet_iterator > 
     class iterator1 
     { 
      int n; 
     }; 
    }; 


    template< typename impl_t, typename utf_t > 
    class tanga 
    { 
     int b; 
    public: 
     typedef typename utf_t::iterator1< typename impl_t::iterator > iterator2; 
     tanga() { 
      iterator2 i; 
     } 
    }; 
} 

typedef utf::tanga< std::string, utf::klar > Hugo; 
static const Hugo h; 

不知道如何解決這個問題?錯誤是:

error: non-template 'iterator1' used as template typedef typename utf_t::iterator1< typename impl_t::iterator > iterator2; 
          ^

回答

5

你需要告訴編譯器iterator1是一個模板用:

typedef typename utf_t::template iterator1< typename impl_t::iterator > iterator2; 
+0

作品!非常感謝! – muffmolch