模板问题,在windows下正常,在linux下编译报错

lurenyy 2011-12-01 12:25:37


template<typename Key,typename Type,typename Allocator>
struct StoreObject
{
StoreObject(const Key & key,const Type &data);

typedef StoreObject<Key,Type,typename Allocator::rebind< Type >::other> ObjectType;
typedef std::list<ObjectType *,typename Allocator::rebind< ObjectType * >::other> ListType;

};


这段代码在windows下使用正常,现在想移植到linux下,编译出错,请大家帮忙看看啦。。
贴出typedef StoreObject<Key,Type,typename Allocator::rebind< Type >::other> ObjectType;这行的错误

error: non-template `rebind' used as template
note: use `Allocator::template rebind' to indicate that it is a template
error: missing `>' to terminate the template argument list
error: template argument 3 is invalid

...全文
144 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
lurenyy 2011-12-01
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 lofeo 的回复:]
typedef typename StoreObject<Key,Type,typename Allocator::rebind< Type >::other> ObjectType;
这样试试。
[/Quote]
还是一样。error: non-template `rebind' used as template
闲的每日C 2011-12-01
  • 打赏
  • 举报
回复
typedef typename StoreObject<Key,Type,typename Allocator::rebind< Type >::other> ObjectType;
这样试试。
夹心饼干 2011-12-01
  • 打赏
  • 举报
回复
上面的是一般的模板
下面个用模板特化,放到一个结构里面?
不同的编译器在编译的时候可能处理不一样
  • 打赏
  • 举报
回复
typedef StoreObject<Key,Type,typename Allocator::template rebind< Type >::other> ObjectType;
typedef std::list<ObjectType *,typename Allocator::template rebind< ObjectType * >::other> ListType;
机智的呆呆 2011-12-01
  • 打赏
  • 举报
回复
linux中gccSTL的实现和windows中vc的实现差别很大~~~

64,651

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧