vector是怎么实现的??

lengmozaixian lengmozaixian 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
我在编程代码中见到类似这样的定义:typedef std::vector<XQQuery*, XQillaAllocator<XQQuery*> > ImportedModules;查找其定义找到一个vector文件
template<class _Ty,
class _Ax>
class vector
: public _Vector_val<_Ty, _Ax>
{ // varying size array of values
public:
typedef vector<_Ty, _Ax> _Myt;
typedef _Vector_val<_Ty, _Ax> _Mybase;
typedef typename _Mybase::_Alty _Alloc;
typedef _Alloc allocator_type;
typedef typename _Alloc::size_type size_type;
typedef typename _Alloc::difference_type _Dift;
typedef _Dift difference_type;
typedef typename _Alloc::pointer _Tptr;
typedef typename _Alloc::const_pointer _Ctptr;
typedef _Tptr pointer;
typedef _Ctptr const_pointer;
typedef typename _Alloc::reference _Reft;
typedef _Reft reference;
typedef typename _Alloc::const_reference const_reference;
typedef typename _Alloc::value_type value_type;

#define _VEC_ITER_BASE(it) (it)._Myptr

这只是一部分代码,我想问的是,此时的vector和STL中的vector一样吗?STL中vector一般都是形如vector<int>或vector< vector<int> >,这里的vector是怎么回事??是不是也可以有vector<int,int>,STL中的容器自己也可以起同样的名字对其重新定义吗?上面vector的形式在后面的代码中也用到了iterator迭代器,若是自己重新定义一个vector也可以用iterator来遍历?
...全文

相关推荐

评论 34
收藏 已收藏
分享
返回顶部
lengmozaixian
C++ 语言 65,212 成员 250,513 内容