insert
,以保留等效元素的插入顺序(问题 #68)。std::size_t
代替unsigned long
来保存和加载multi_index_container
的大小(在 LLP64 数据模型中,unsigned long
小于std::size_t
)。multi_index_container
序列化类版本已从 3 升级到 4 以反映此更改。
unsigned long
代替collection_size_type
,并且multi_index_container
序列化类版本已从 2 升级到 3 以反映此更改。对于对collection_size_type
值进行特殊处理的自定义存档类型,读取旧存档可能会失败:如果出现这种情况,请全局定义宏BOOST_MULTI_INDEX_ENABLE_SERIALIZATION_COMPATIBILITY_V2
以确保读取操作向后兼容。
count
操作的效率从O(log(n) + count)
提高到O(log(n))
。由 Damian Sawicki 贡献。
contains
(问题 #35)。merge
操作。该功能在许多方面都超越了(无序)关联容器的标准规范,最值得注意的是x.merge(y,first,last)
仅合并y
中[first
,last
)范围内的元素。splice
是破坏性的,即元素被复制插入到目标中,然后从源中删除。现在,splice
基于节点转移,就像基于键的索引中的merge
一样,并且类似地扩展为接受任何类型的源索引:事实上,splice
可以被认为是基于键的索引中merge
提供功能的接口。出于向后兼容性的原因,如果源容器和目标容器的分配器不相等,则保留了splice
的破坏性行为。node_type
以及索引在其multi_index_container
中的位置(哈希索引除外,其中唯一性/非唯一性也是依赖项)。这会影响由merge
或splice
转移的元素的迭代器的有效性。此属性是 C++ 标准邮件列表中所谓的SCARY 迭代器的变体。SCARY性目前(2021 年 8 月)并非标准容器的强制要求。
multi_index_container
现在是AllocatorAware
。KeyFromValue
、Compare
、Hash
和Pred
对象的交换现在选择std::swap
和ADL候选者之间的适当swap
函数,符合[swappable.requirements]中的标准规范(问题 #29)。
const_mem_fun
和mem_fun
的变体(问题 #24)。noexcept
指定的成员函数(问题 #24)。
size_type
和difference_type
现在定义为分配器的同名类型。这在绝大多数情况下都不会有任何区别,但允许通过用户定义的分配器类型在一定程度上控制生成的内部结构(有关动机,请参见问题 #17)。目前,此更改未记录在参考部分(即,它具有半官方状态)。
multi_index_container
的默认构造函数不再是explicit
(工单#13518)。
operator&
的元素(工单#13307)。感谢 Daniel Frey 更新了Boost.Operators以帮助解决此问题。std::allocator
成员。由 Daniela Engert 贡献。
modify
和modify_key
更加健壮,以便如果修改器抛出异常或回滚函数没有正确恢复元素,则删除修改后的元素(在工单#12542中进行了全面讨论)。这在技术上是向后不兼容的;例如,以下代码在以前的 Boost 版本中保持容器c.modify(c.begin(),[](auto&){throw 0;});
c
不变,而现在c.begin()
被删除。感谢 Jon Kalb 提出此问题。
foreach
的宏而导致的与Qt的互操作性问题。
key_type
的临时值的情况下,查找操作的效率得到了提高。例如,考虑以下代码在以前的库版本中,typedef multi_index_container< std::string, indexed_by< ordered_unique<identity<std::string> > > > multi_t; ... multi_t m=...; m.find("boost"); // passed a const char*, not a std::string
find
操作会生成多个临时std::string
(每次进行内部比较时都会生成一个)。在足够先进的编译器中,现在避免了这种情况,因此只创建一个临时变量。
std::tuple
可用时,这些可以用于配备复合键的索引中的查找操作。boost::tuple
也为了向后兼容性而受支持。
erase(iterator)
成员函数在低负载条件下的性能较差(请参见工单#4264)。根据LWG 问题 #579的决议,此问题已在保持erase
接口的同时得到修复,代价是每个元素多使用一个内存字。事实上,哈希索引的无序关联容器的 C++ 复杂性要求得到了改进,因此O(n)
而是O(ndist)
,其中ndist
是索引中非等效元素的数量。reserve
。noexcept
规范(对于兼容的编译器)。multi_index_container
中插入失败的性能。BOOST_BIND_NO_PLACEHOLDERS
(工单 #9798)。
multi_index_container
现在可以高效地移动。std::unique_ptr<T>
)。这包括插入一个范围 [first
,last
),其中迭代器指向可转换为元素类型的类型:在此过程中不会发生复制构造。shrink_to_fit()
。
composite_key_compare
中与 Boost.Ref 相关的 ADL 问题。
save_construct_data
和 load_construct_data
正确支持 非默认可构造值的序列化。multi_index_container
序列化的 类版本 已从 1 提升到 2。
collection_size_type
类型而不是原来的 std::size_t
(工单 #3365)。multi_index_container
序列化的 类版本 已从 0 提升到 1。
nth_index_iterator<MultiIndexContainer,N>::type
,multi_index_container<...>::nth_index_iterator<N>::type
,nth_index_const_iterator<MultiIndexContainer,N>::type
,multi_index_container<...>::nth_index_const_iterator<N>::type
,index_iterator<MultiIndexContainer,Tag>::type
,multi_index_container<...>::index_iterator<Tag>::type
,index_const_iterator<MultiIndexContainer,Tag>::type
,multi_index_container<...>::index_const_iterator<Tag>::type
.nth_index<MultiIndexContainer,N>::type::iterator
,multi_index_container<...>::nth_index<N>::type::iterator
,nth_index<MultiIndexContainer,N>::type::const_iterator
,multi_index_container<...>::nth_index<N>::type::const_iterator
,index<MultiIndexContainer,Tag>::type::iterator
,multi_index_container<...>::index<Tag>::type::iterator
,index<MultiIndexContainer,Tag>::type::const_iterator
,multi_index_container<...>::index<Tag>::type::const_iterator
.
multi_index_container::multi_index_container(const allocator_type&)
以模仿 STL 顺序容器中的等效接口。
global_fun
预定义键提取器。iterator_to
功能。multi_index_container
可以放置在共享内存中。modify
和 modify_key
版本,如 教程 中所述。cbegin
、cend
以及(在适用时)crbegin
和 crend
成员函数。assign(f,l)
和 insert(p,f,l)
(23.1.1/9) 的要求:如果 f
和 l
是相同的整数类型,则避免使用这些成员函数的基于迭代器的重载。typedef multi_index_container< int,indexed_by<sequenced<> > > sequenced_container; std::list<int> l(...); sequenced_container c; // iterator-based overload of assign c.assign(l.begin(),l.end()); // The following is equivalent to // c.assign( // static_cast<sequenced_container::size_type>(10),100); // that is, "10" and "100" are not taken to be iterators as // in the previous expression. c.assign(10,100);
range
和 equal_range
的性能。
T
实例化的所有预定义 Boost.MultiIndex 键提取器都可以处理派生自或可转换为 T
的类型对象(以及指向这些对象的 链式指针)。以前,只接受指定的确切类型对象(以及 reference_wrapper
和指向它们的链式指针)。composite_key_compare
和相关类接受元组中未包含的操作数,就好像它们在一个长度为 1 的元组中传递一样;这允许用户在只提供第一个键时,省略在涉及复合键的查找操作中的元组封装。
erase(it)
和 erase(first,last)
现在返回一个指向被删除元素后的元素的迭代器(以前不返回任何内容),这符合 C++ 标准库 缺陷报告 130 和 TR1 的 6.19 问题 问题列表。
multi_index_container
的析构和 clear
成员函数现在执行速度更快。2024 年 3 月 15 日修订
© 版权所有 2003-2024 Joaquín M López Muñoz。根据 Boost 软件许可证版本 1.0 分发。(参见随附文件 LICENSE_1_0.txt 或复制自 https://boost.ac.cn/LICENSE_1_0.txt)