免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2692 | 回复: 2
打印 上一主题 下一主题

gcc stl里面的神奇代码 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2008-01-31 15:43 |只看该作者 |倒序浏览
这个特化类,看起来一样。难道高手们出错了?

  1.       template<typename _Key_compare,
  2.                bool _Is_pod_comparator = std::__is_pod<_Key_compare>::_M_type>
  3.         struct _Rb_tree_impl : public _Node_allocator
  4.         {
  5.           _Key_compare                _M_key_compare;
  6.           _Rb_tree_node_base         _M_header;
  7.           size_type                 _M_node_count; // Keeps track of size of tree.

  8.           _Rb_tree_impl(const _Node_allocator& __a = _Node_allocator(),
  9.                         const _Key_compare& __comp = _Key_compare())
  10.           : _Node_allocator(__a), _M_key_compare(__comp), _M_node_count(0)
  11.           {
  12.             this->_M_header._M_color = _S_red;
  13.             this->_M_header._M_parent = 0;
  14.             this->_M_header._M_left = &this->_M_header;
  15.             this->_M_header._M_right = &this->_M_header;
  16.           }
  17.         };

  18.       // Specialization for _Comparison types that are not capable of
  19.       // being base classes / super classes.
  20.       template<typename _Key_compare>
  21.         struct _Rb_tree_impl<_Key_compare, true> : public _Node_allocator
  22.         {
  23.           _Key_compare                 _M_key_compare;
  24.           _Rb_tree_node_base         _M_header;
  25.           size_type                 _M_node_count; // Keeps track of size of tree.

  26.           _Rb_tree_impl(const _Node_allocator& __a = _Node_allocator(),
  27.                         const _Key_compare& __comp = _Key_compare())
  28.           : _Node_allocator(__a), _M_key_compare(__comp), _M_node_count(0)
  29.           {
  30.             this->_M_header._M_color = _S_red;
  31.             this->_M_header._M_parent = 0;
  32.             this->_M_header._M_left = &this->_M_header;
  33.             this->_M_header._M_right = &this->_M_header;
  34.           }
  35.         };
复制代码
kenmark 该用户已被删除
2 [报告]
发表于 2008-01-31 17:26 |只看该作者
提示: 作者被禁止或删除 内容自动屏蔽

论坛徽章:
0
3 [报告]
发表于 2008-01-31 18:24 |只看该作者
原帖由 kenmark 于 2008-1-31 17:26 发表
template
  
template
        struct _Rb_tree_impl : public _Node_allocator
对于_Is_pod_comparator 是 true的特化,很有用~


有用在哪里,它特化后的代码和原来一样呢
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP