我对嵌套模板类有一些问题。代码在VS2012中编译良好,但在VS2013和gcc 4.2.x中失败:
#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;
^
答案 0 :(得分:5)
您需要告诉编译器iterator1
是一个模板:
typedef typename utf_t::template iterator1< typename impl_t::iterator > iterator2;