《stlport》源码解析-vector

(1)打开stlport 的源码了吗,我这里使用4.6.2版本,其他版本也无妨啊。

(2)进入stlport/stl目录,有木有很多_list.h,_vector.h的文件,恭喜你找对了。

(3)打开_vector.h看看吧,建议用UE或者其他IDE环境,这样方便看哦。

(4)

template <class _Tp, class _Alloc> 
class _Vector_base {
public:

  _STLP_FORCE_ALLOCATORS(_Tp, _Alloc)
  typedef typename _Alloc_traits<_Tp, _Alloc>::allocator_type allocator_type;

  _Vector_base(const _Alloc& __a)
    : _M_start(0), _M_finish(0), _M_end_of_storage(__a, 0) {
  }
  _Vector_base(size_t __n, const _Alloc& __a)
    : _M_start(0), _M_finish(0), _M_end_of_storage(__a, 0)
  {
    _M_start = _M_end_of_storage.allocate(__n);
    _M_finish = _M_start;
    _M_end_of_storage._M_data = _M_start + __n;
	_STLP_MPWFIX_TRY _STLP_MPWFIX_CATCH
  }

  ~_Vector_base() { 
    if (_M_start !=0) 
    _M_end_of_storage.deallocate(_M_start, _M_end_of_storage._M_data - _M_start); 
  }

protected:
  _Tp* _M_start;
  _Tp* _M_finish;
  _STLP_alloc_proxy<_Tp*, _Tp, allocator_type> _M_end_of_storage;
};

(5)

(6)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值