《coredump问题原理探究》Linux x86版7.7节 set对象

看一下bits/stl_map和bits/stl_set可以看到map和set的定义如下:

 

 

84   template <typename _Key, typename _Tp, typename _Compare = std::less<_Key>,
 85             typename _Alloc = std::allocator<std::pair<const _Key, _Tp> > >
 86     class map
 87     {
 88     public:
 89       typedef _Key                                          key_type;
 90       typedef _Tp                                           mapped_type;
 91       typedef std::pair<const _Key, _Tp>                    value_type;
 92       typedef _Compare                                      key_compare;
 93       typedef _Alloc                                        allocator_type;
 94 
 95     private:
 96       // concept requirements
 97       typedef typename _Alloc::value_type                   _Alloc_value_type;
 98       __glibcxx_class_requires(_Tp, _SGIAssignableConcept)
 99       __glibcxx_class_requires4(_Compare, bool, _Key, _Key,
100                 _BinaryFunctionConcept)
101       __glibcxx_class_requires2(value_type, _Alloc_value_type, _SameTypeConcept)
102 
103     public:
104       class value_compare
105       : public std::binary_function<value_type, value_type, bool>
106       {
107     friend class map<_Key, _Tp, _Compare, _Alloc>;
108       protected:
109     _Compare comp;
110 
111     value_compare(_Compare __c)
112     : comp(__c) { }
113 
114       public:
115     bool operator()(const value_type& __x, const value_type& __y) const
116     { return comp(__x.first, __y.first); }
117       };
118 
119     private:
120       /// This turns a red-black tree into a [multi]map. 
121       typedef typename _Alloc::template rebind<value_type>::other
122         _Pair_alloc_type;
123 
124       typedef _Rb_tree<key_type, value_type, _Select1st<value_type>,
125                key_compare, _Pair_alloc_type> _Rep_type;
126 
127       /// The actual tree structure.
128       _Rep_type _M_t;

 

 

 

 

85   template<typename _Key, typename _Compare = std::less<_Key>,
 86        typename _Alloc = std::allocator<_Key> >
 87     class set
 88     {
 89       // concept requirements
 90       typedef typename _Alloc::value_type                   _Alloc_value_type;
 91       __glibcxx_class_requires(_Key, _SGIAssignableConcept)
 92       __glibcxx_class_requires4(_Compare, bool, _Key, _Key,
 93                 _BinaryFunctionConcept)
 94       __glibcxx_class_requires2(_Key, _Alloc_value_type, _SameTypeConcept)
 95 
 96     public:
 97       // typedefs:
 98       //@{
 99       /// Public typedefs.
100       typedef _Key     key_type;
101       typedef _Key     value_type;
102       typedef _Compare key_compare;
103       typedef _Compare value_compare;
104       typedef _Alloc   allocator_type;
105       //@}
106 
107     private:
108       typedef typename _Alloc::template rebind<_Key>::other _Key_alloc_type;
109 
110       typedef _Rb_tree<key_type, value_type, _Identity<value_type>,
111                key_compare, _Key_alloc_type> _Rep_type;
112       _Rep_type _M_t;  // Red-black tree representing set.
113

 

 

 

更多内容请关注微信公众号"debugeeker", 链接为https://mp.weixin.qq.com/s/XGTfJaGmbVEq5d32FR4FiA

 

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值