读书人

大伙儿看下面这个代码中向量迭代器的_

发布时间: 2014-01-09 23:07:34 作者: rapoo

大家看下面这个代码中向量迭代器的_Myptr变量用什么代替,源程序的无发编译通过

template<class T> inline uintmax_idx( const vector<T> &v )
{
return (uint)(max_element(v.begin(),v.end())._Myptr-v.begin()._Myptr);
}

上面是源代码,编译后出现错误

1>e:\research\coding\tracking\miltracker-v1.0\boosttrackerpublic\Public.h(184): error C2039: “_Myptr”: 不是“std::_Vector_const_iterator<_Myvec>”的成员
1> with
1> [
1> _Myvec=std::_Vector_val<float,std::allocator<float>>
1> ]
1> Generating Code...
1>


那大家看这个应该怎么解决呢?应该有这个_Myptr的替代品吧,其实vc中用查看定义能够找他在vector.h中有一个这个,不过是在iterator_12里面定义的,求高手们来解决这个问题,谢谢。


[解决办法]
我这测试了,没有压力的通过了,我也看了这个的声明它是做为了

auto_ptr的成员 _Ty *_Myptr;


allocator<void>类模版中的 typedef void _Ty;

[解决办法]
我这没有任何问题呀,编译都通过了

读书人网 >C++

热点推荐