【发布时间】:2018-03-02 07:03:59
【问题描述】:
我试图查看 libstdc++ 的 std::multiset 实现(只是因为我很好奇),我发现了这一行 https://github.com/gcc-mirror/gcc/blob/master/libstdc%2B%2B-v3/include/bits/stl_multiset.h#L118,但不知道该怎么做。我理解它的方式,_Rb_tree class 是一个单元素树,那条线是如何把它变成一个多重集的?
按照我的理解,该行只是将分配器调整为另一种类型。还是我理解错了?
这是链接代码
private:
/// This turns a red-black tree into a [multi]set.
typedef typename __gnu_cxx::__alloc_traits<_Alloc>::template
rebind<_Key>::other _Key_alloc_type;
typedef _Rb_tree<key_type, value_type, _Identity<value_type>,
key_compare, _Key_alloc_type> _Rep_type;
/// The actual tree structure.
_Rep_type _M_t;
【问题讨论】:
-
您能否在问题中包含您所质疑的代码而不是使用链接?
-
@1201ProgramAlarm 完成
标签: c++ c++11 gcc libstdc++ multiset