vc6 编译器的问题

hdqqq 2006-01-13 03:11:51
void list_test()
{
list<int> l;
list<int>::iterator lp;
list<int>::const_iterator cp;
list<int>::reverse_iterator rp;
list<int>::const_reverse_iterator crp;
lp = l.begin();
cp = l.begin();
rp = l.rbegin();
crp = l.rbegin();
}
在vc6 sp6 上, 上面的函数居然是编译不过的.
在于 crp = l.rbegin(); 这句
产生的错误是
error C2679: binary '=' : no operator defined which takes a right-hand operand of type 'class std::reverse_bidirectional_iterator<class std::list<int,class std::allocator<int> >::iterator,int,
int &,int *,int>' (or there is no acceptable conversion)
Error executing cl.exe.
关键是编译器认为
l.rbegin() 返回的是一个 reverse_iterator, 所以没有办法将 reverse_iterator 转换为 const_reverse_iterator, 即使在stl 的list 中定义了
const_reverse_iterator rbegin() const; 也没有用,真的是一个很奇怪的问题.


...全文
108 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
hdqqq 2006-01-13
  • 打赏
  • 举报
回复
上面的问题在vs 2003 上的编译器上可以编译通过,看来 vs 2003 的编译器是比vc6提高了很多.

1,649

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 非技术类
社区管理员
  • 非技术类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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