XXX is parsed as a non-type, but instantiation yields a type 错误解决办法
来源:互联网 发布:openstack 外部网络 编辑:程序博客网 时间:2024/04/25 15:19
最近在写程序的时候遇到了XXX is parsed as a non-type, but instantiation yields a type 的错误。程序上下文如下
template<typename FullKey,// base containe typename PolicyTraits >class container_with_policy{private:FullKey m_cache;//initialize firstpublic:struct container_element{typename PolicyTraits::policy_hook_type policy_hook_;typename FullKey::iterator m_iterator;typedef typename PolicyTraits::template container_hook<container_element>::type PolicyHook;typename FullKey::iterator& operator&(){return m_iterator;};container_element& operator=(typename FullKey::iterator& it){m_iterator=it;return *this;}container_element(){};container_element(const typename FullKey::iterator& it):m_iterator(it){}};typedef typename FullKey::iterator iterator;typedef typename FullKey::const_iterator const_iterator;typedef typename PolicyTraits::template policy<FullKey,container_element,container_element::PolicyHook >::type policy_container;typedef typename FullKey::value_type base_element_type;///////////////////////////////////////////////////////////////////////////////container_with_policy();~container_with_policy();};在
<pre name="code" class="cpp">container_element::PolicyHook >::type policy_container;这一行里,编译器提示
error: dependent-name ‘ns3::ndn::container_with_policy<FullKey, PolicyTraits>::container_element:: PolicyHook’ is parsed as a non-type, but instantiation yields a type container_element::PolicyHook >::type policy_container;
大意是说PolicyHook在编译器看来不是一个类型,但是却要它作为一个类型来使用。
但是没理由啊,
typedef typename PolicyTraits::template container_hook<container_element>::type PolicyHook;
这里已经把PolicyHook作为一个typedef了。
仔细看看,原来凡是typedef的内容,在使用的时候,要在前面加上typename, 否则编译器搞不清楚这个到底是你写错了还是真的有这个类型。
修改方法:
把container_element::PolicyHook前面添加typename,改成typename container_element::PolicyHook即可,结果错误消失了。
0 0
- XXX is parsed as a non-type, but instantiation yields a type 错误解决办法
- eclipse编译器出现Type Class 'XXX' has virtual method 'XXX' but non-virtual destructor的解决办法
- Solaris 10 如何解决:/usr/include/sys/siginfo.h:259: error: 'ctid_t' is used as a type, but is not
- Receiver XXX type for instance message is a forward declaration
- Receiver XXX type for instance message is a forward declaration
- Receiver XXX type for instance message is a forward declaration
- xxx cannot be resolved to a type 错误解决方法
- xxx cannot be resolved to a type 错误分析
- xxx cannot be resolved to a type 错误解决方法
- xxx cannot be resolved to a type 错误解决方法
- xxx cannot be resolved to a type 错误解决方法
- xxx cannot be resolved to a type 错误解决方法
- xxx cannot be resolved to a type 错误解决方法
- xxx cannot be resolved to a type 错误解决方法
- xxx cannot be resolved to a type 错误解决方法
- xxx cannot be resolved to a type 错误解决方法
- xxx cannot be resolved to a type 错误解决方法
- xxx cannot be resolved to a type 错误解决方法
- 主妇注意:猛火炒菜 易患肺癌
- iOS第三方MagicalRecord
- php中的round函数的bug
- 执着的人
- $取shell参数
- XXX is parsed as a non-type, but instantiation yields a type 错误解决办法
- 浅谈iOS中MVVM的架构设计与团队协作
- GDI+ for VC6 MFC
- 小怪物项目重制计划第一天
- XML Schema基本用法
- 显式和隐式启动activity
- Ubuntu的内核转储工具
- 整理ECMall模板解析语法与机制
- uva 1352 Colored Cubes(枚举)