mirror of
https://github.com/boostorg/container.git
synced 2025-08-01 05:24:31 +02:00
Sync from upstream.
This commit is contained in:
@@ -1418,7 +1418,8 @@ use [*Boost.Container]? There are several reasons for that:
|
|||||||
* [@https://github.com/boostorg/container/issues/275 GitHub #275: ['"Compilation fails if custom key comparison is used"]].
|
* [@https://github.com/boostorg/container/issues/275 GitHub #275: ['"Compilation fails if custom key comparison is used"]].
|
||||||
* [@https://github.com/boostorg/container/issues/273 GitHub #273: ['"flat_map/vector crashes on appends (memory corruption)"]].
|
* [@https://github.com/boostorg/container/issues/273 GitHub #273: ['"flat_map/vector crashes on appends (memory corruption)"]].
|
||||||
* [@https://github.com/boostorg/container/issues/269 GitHub #269: ['"flat_multimap::emplace not sorting elements under GCC"]].
|
* [@https://github.com/boostorg/container/issues/269 GitHub #269: ['"flat_multimap::emplace not sorting elements under GCC"]].
|
||||||
* [@https://github.com/boostorg/container/issues/269 GitHub #269: ['"flat_multimap::emplace not sorting elements under GCC"]].
|
* [@https://github.com/boostorg/container/issues/266 GitHub #266: ['"small_vector<T> is misaligned on the stack in 32 bits"]].
|
||||||
|
* [@https://github.com/boostorg/container/issues/245 GitHub #245: ['"flat_tree::insert ordered range doesn't assert sorting"]].
|
||||||
|
|
||||||
[endsect]
|
[endsect]
|
||||||
|
|
||||||
|
@@ -26,7 +26,6 @@
|
|||||||
|
|
||||||
#include <boost/move/utility_core.hpp>
|
#include <boost/move/utility_core.hpp>
|
||||||
|
|
||||||
#include <boost/container/detail/pair.hpp>
|
|
||||||
#include <boost/container/vector.hpp>
|
#include <boost/container/vector.hpp>
|
||||||
#include <boost/container/allocator_traits.hpp>
|
#include <boost/container/allocator_traits.hpp>
|
||||||
|
|
||||||
@@ -955,6 +954,7 @@ class flat_tree
|
|||||||
template <class InIt>
|
template <class InIt>
|
||||||
void insert_equal(ordered_range_t, InIt first, InIt last)
|
void insert_equal(ordered_range_t, InIt first, InIt last)
|
||||||
{
|
{
|
||||||
|
BOOST_ASSERT((is_sorted)(first, last, this->priv_value_comp()));
|
||||||
const bool value = boost::container::dtl::
|
const bool value = boost::container::dtl::
|
||||||
has_member_function_callable_with_merge_unique<container_type, InIt, InIt, value_compare>::value;
|
has_member_function_callable_with_merge_unique<container_type, InIt, InIt, value_compare>::value;
|
||||||
(flat_tree_merge_equal)(this->m_data.m_seq, first, last, this->priv_value_comp(), dtl::bool_<value>());
|
(flat_tree_merge_equal)(this->m_data.m_seq, first, last, this->priv_value_comp(), dtl::bool_<value>());
|
||||||
@@ -963,6 +963,7 @@ class flat_tree
|
|||||||
template <class InIt>
|
template <class InIt>
|
||||||
void insert_unique(ordered_unique_range_t, InIt first, InIt last)
|
void insert_unique(ordered_unique_range_t, InIt first, InIt last)
|
||||||
{
|
{
|
||||||
|
BOOST_ASSERT((is_sorted_and_unique)(this->m_data.m_seq.cbegin(), this->m_data.m_seq.cend(), this->priv_value_comp()));
|
||||||
const bool value = boost::container::dtl::
|
const bool value = boost::container::dtl::
|
||||||
has_member_function_callable_with_merge_unique<container_type, InIt, InIt, value_compare>::value;
|
has_member_function_callable_with_merge_unique<container_type, InIt, InIt, value_compare>::value;
|
||||||
(flat_tree_merge_unique)(this->m_data.m_seq, first, last, this->priv_value_comp(), dtl::bool_<value>());
|
(flat_tree_merge_unique)(this->m_data.m_seq, first, last, this->priv_value_comp(), dtl::bool_<value>());
|
||||||
|
@@ -38,6 +38,7 @@
|
|||||||
#include <boost/container/detail/type_traits.hpp>
|
#include <boost/container/detail/type_traits.hpp>
|
||||||
#include <boost/container/detail/version_type.hpp>
|
#include <boost/container/detail/version_type.hpp>
|
||||||
#include <boost/container/detail/is_pair.hpp>
|
#include <boost/container/detail/is_pair.hpp>
|
||||||
|
#include <boost/container/detail/pair.hpp>
|
||||||
// intrusive
|
// intrusive
|
||||||
#include <boost/intrusive/detail/mpl.hpp>
|
#include <boost/intrusive/detail/mpl.hpp>
|
||||||
#include <boost/intrusive/options.hpp>
|
#include <boost/intrusive/options.hpp>
|
||||||
|
@@ -29,7 +29,7 @@
|
|||||||
#include <boost/container/detail/type_traits.hpp>
|
#include <boost/container/detail/type_traits.hpp>
|
||||||
#include <boost/container/detail/mpl.hpp>
|
#include <boost/container/detail/mpl.hpp>
|
||||||
#include <boost/container/detail/std_fwd.hpp>
|
#include <boost/container/detail/std_fwd.hpp>
|
||||||
#include <boost/container/detail/is_pair.hpp>
|
#include <boost/container/detail/is_pair.hpp> //Forward declares boost::tuples::tuple
|
||||||
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||||
# include <boost/container/detail/variadic_templates_tools.hpp>
|
# include <boost/container/detail/variadic_templates_tools.hpp>
|
||||||
#endif
|
#endif
|
||||||
|
@@ -31,6 +31,7 @@
|
|||||||
#include <boost/container/detail/mpl.hpp>
|
#include <boost/container/detail/mpl.hpp>
|
||||||
#include <boost/container/detail/algorithm.hpp> //equal()
|
#include <boost/container/detail/algorithm.hpp> //equal()
|
||||||
#include <boost/container/detail/container_or_allocator_rebind.hpp>
|
#include <boost/container/detail/container_or_allocator_rebind.hpp>
|
||||||
|
#include <boost/container/detail/pair.hpp>
|
||||||
// move
|
// move
|
||||||
#include <boost/move/utility_core.hpp>
|
#include <boost/move/utility_core.hpp>
|
||||||
#include <boost/move/traits.hpp>
|
#include <boost/move/traits.hpp>
|
||||||
@@ -44,6 +45,7 @@
|
|||||||
#include <boost/intrusive/detail/minimal_pair_header.hpp> //pair
|
#include <boost/intrusive/detail/minimal_pair_header.hpp> //pair
|
||||||
#include <boost/intrusive/detail/minimal_less_equal_header.hpp>//less, equal
|
#include <boost/intrusive/detail/minimal_less_equal_header.hpp>//less, equal
|
||||||
|
|
||||||
|
|
||||||
#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
|
#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
|
||||||
#include <initializer_list>
|
#include <initializer_list>
|
||||||
#endif
|
#endif
|
||||||
@@ -1673,7 +1675,7 @@ class flat_map
|
|||||||
if (i == end() || key_comp()(k, (*i).first)){
|
if (i == end() || key_comp()(k, (*i).first)){
|
||||||
dtl::value_init<mapped_type> m;
|
dtl::value_init<mapped_type> m;
|
||||||
impl_value_type v(k, ::boost::move(m.m_t));
|
impl_value_type v(k, ::boost::move(m.m_t));
|
||||||
i = this->insert(i, ::boost::move(v));
|
i = dtl::force_copy<iterator>(this->m_flat_tree.insert_equal(::boost::move(v)));
|
||||||
}
|
}
|
||||||
return (*i).second;
|
return (*i).second;
|
||||||
}
|
}
|
||||||
@@ -1682,10 +1684,10 @@ class flat_map
|
|||||||
key_type &k = mk;
|
key_type &k = mk;
|
||||||
iterator i = this->lower_bound(k);
|
iterator i = this->lower_bound(k);
|
||||||
// i->first is greater than or equivalent to k.
|
// i->first is greater than or equivalent to k.
|
||||||
if (i == end() || key_comp()(k, (*i).first)){
|
if (i == end() || key_comp()(k, (*i).first)) {
|
||||||
dtl::value_init<mapped_type> m;
|
dtl::value_init<mapped_type> m;
|
||||||
impl_value_type v(::boost::move(k), ::boost::move(m.m_t));
|
impl_value_type v(::boost::move(k), ::boost::move(m.m_t));
|
||||||
i = this->insert(i, ::boost::move(v));
|
i = dtl::force_copy<iterator>(this->m_flat_tree.insert_equal(::boost::move(v)));
|
||||||
}
|
}
|
||||||
return (*i).second;
|
return (*i).second;
|
||||||
}
|
}
|
||||||
@@ -1765,7 +1767,7 @@ flat_map(ordered_unique_range_t, InputIterator, InputIterator, Compare const&, A
|
|||||||
template <class Key, class T, class Compare, class AllocatorOrContainer>
|
template <class Key, class T, class Compare, class AllocatorOrContainer>
|
||||||
struct has_trivial_destructor_after_move<boost::container::flat_map<Key, T, Compare, AllocatorOrContainer> >
|
struct has_trivial_destructor_after_move<boost::container::flat_map<Key, T, Compare, AllocatorOrContainer> >
|
||||||
{
|
{
|
||||||
typedef ::boost::container::dtl::pair<Key, T> value_t;
|
typedef typename boost::container::flat_map<Key, T, Compare, AllocatorOrContainer>::value_type value_t;
|
||||||
typedef typename ::boost::container::dtl::container_or_allocator_rebind<AllocatorOrContainer, value_t>::type alloc_or_cont_t;
|
typedef typename ::boost::container::dtl::container_or_allocator_rebind<AllocatorOrContainer, value_t>::type alloc_or_cont_t;
|
||||||
typedef ::boost::container::dtl::flat_tree<value_t,::boost::container::dtl::select1st<Key>, Compare, alloc_or_cont_t> tree;
|
typedef ::boost::container::dtl::flat_tree<value_t,::boost::container::dtl::select1st<Key>, Compare, alloc_or_cont_t> tree;
|
||||||
BOOST_STATIC_CONSTEXPR bool value = ::boost::has_trivial_destructor_after_move<tree>::value;
|
BOOST_STATIC_CONSTEXPR bool value = ::boost::has_trivial_destructor_after_move<tree>::value;
|
||||||
@@ -3099,7 +3101,7 @@ namespace boost {
|
|||||||
template <class Key, class T, class Compare, class AllocatorOrContainer>
|
template <class Key, class T, class Compare, class AllocatorOrContainer>
|
||||||
struct has_trivial_destructor_after_move< boost::container::flat_multimap<Key, T, Compare, AllocatorOrContainer> >
|
struct has_trivial_destructor_after_move< boost::container::flat_multimap<Key, T, Compare, AllocatorOrContainer> >
|
||||||
{
|
{
|
||||||
typedef ::boost::container::dtl::pair<Key, T> value_t;
|
typedef typename boost::container::flat_multimap<Key, T, Compare, AllocatorOrContainer>::value_type value_t;
|
||||||
typedef typename ::boost::container::dtl::container_or_allocator_rebind<AllocatorOrContainer, value_t>::type alloc_or_cont_t;
|
typedef typename ::boost::container::dtl::container_or_allocator_rebind<AllocatorOrContainer, value_t>::type alloc_or_cont_t;
|
||||||
typedef ::boost::container::dtl::flat_tree<value_t,::boost::container::dtl::select1st<Key>, Compare, alloc_or_cont_t> tree;
|
typedef ::boost::container::dtl::flat_tree<value_t,::boost::container::dtl::select1st<Key>, Compare, alloc_or_cont_t> tree;
|
||||||
BOOST_STATIC_CONSTEXPR bool value = ::boost::has_trivial_destructor_after_move<tree>::value;
|
BOOST_STATIC_CONSTEXPR bool value = ::boost::has_trivial_destructor_after_move<tree>::value;
|
||||||
|
@@ -36,7 +36,7 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
<PlatformToolset>v143</PlatformToolset>
|
<PlatformToolset>v90</PlatformToolset>
|
||||||
<CharacterSet>MultiByte</CharacterSet>
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||||
|
@@ -36,7 +36,7 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
<PlatformToolset>v143</PlatformToolset>
|
<PlatformToolset>v90</PlatformToolset>
|
||||||
<CharacterSet>MultiByte</CharacterSet>
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||||
|
@@ -36,7 +36,7 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
<PlatformToolset>v143</PlatformToolset>
|
<PlatformToolset>ClangCL</PlatformToolset>
|
||||||
<CharacterSet>MultiByte</CharacterSet>
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||||
|
@@ -11,6 +11,7 @@
|
|||||||
#include <boost/container/small_vector.hpp>
|
#include <boost/container/small_vector.hpp>
|
||||||
#include <boost/container/stable_vector.hpp>
|
#include <boost/container/stable_vector.hpp>
|
||||||
#include <boost/container/static_vector.hpp>
|
#include <boost/container/static_vector.hpp>
|
||||||
|
#include <boost/container/detail/pair.hpp>
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
@@ -865,8 +865,9 @@ int map_test_search(MyBoostMap &boostmap, MyStdMap &stdmap, MyBoostMultiMap &boo
|
|||||||
template<class MyBoostMap
|
template<class MyBoostMap
|
||||||
, class MyStdMap
|
, class MyStdMap
|
||||||
, class MyBoostMultiMap
|
, class MyBoostMultiMap
|
||||||
, class MyStdMultiMap>
|
, class MyStdMultiMap
|
||||||
int map_test_indexing(MyBoostMap &boostmap, MyStdMap &stdmap, MyBoostMultiMap &boostmultimap, MyStdMultiMap &stdmultimap)
|
, class Other>
|
||||||
|
int map_test_indexing(MyBoostMap &boostmap, MyStdMap &stdmap, MyBoostMultiMap &boostmultimap, MyStdMultiMap &stdmultimap, boost::container::dtl::true_type, Other)
|
||||||
{
|
{
|
||||||
typedef typename MyBoostMap::key_type IntType;
|
typedef typename MyBoostMap::key_type IntType;
|
||||||
typedef dtl::pair<IntType, IntType> IntPairType;
|
typedef dtl::pair<IntType, IntType> IntPairType;
|
||||||
@@ -883,18 +884,102 @@ int map_test_indexing(MyBoostMap &boostmap, MyStdMap &stdmap, MyBoostMultiMap &b
|
|||||||
IntType i2(i);
|
IntType i2(i);
|
||||||
new(&aux_vect[i])IntPairType(boost::move(i1), boost::move(i2));
|
new(&aux_vect[i])IntPairType(boost::move(i1), boost::move(i2));
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
for(int i = 0; i < MaxElem; ++i){
|
for(int i = 0; i < MaxElem; ++i){
|
||||||
boostmap[boost::move(aux_vect[i].first)] = boost::move(aux_vect[i].second);
|
boostmap[boost::move(aux_vect[i].first)] = boost::move(aux_vect[i].second);
|
||||||
stdmap[i] = i;
|
stdmap[i] = i;
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
if(!CheckEqualPairContainers(boostmap, stdmap)) return 1;
|
if(!CheckEqualPairContainers(boostmap, stdmap)) return 1;
|
||||||
if(!CheckEqualPairContainers(boostmultimap, stdmultimap)) return 1;
|
if(!CheckEqualPairContainers(boostmultimap, stdmultimap)) return 1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<class MyBoostMap
|
||||||
|
, class MyStdMap
|
||||||
|
, class MyBoostMultiMap
|
||||||
|
, class MyStdMultiMap>
|
||||||
|
int map_test_indexing_move_assignable(MyBoostMap& boostmap, MyStdMap& stdmap, MyBoostMultiMap& boostmultimap, MyStdMultiMap& stdmultimap, boost::container::dtl::true_type)
|
||||||
|
{
|
||||||
|
typedef typename MyBoostMap::key_type IntType;
|
||||||
|
typedef dtl::pair<IntType, IntType> IntPairType;
|
||||||
|
|
||||||
|
{ //operator[] test
|
||||||
|
boostmap.clear();
|
||||||
|
boostmultimap.clear();
|
||||||
|
stdmap.clear();
|
||||||
|
stdmultimap.clear();
|
||||||
|
|
||||||
|
IntPairType aux_vect[(std::size_t)MaxElem];
|
||||||
|
for (int i = 0; i < MaxElem; ++i) {
|
||||||
|
IntType i1(i);
|
||||||
|
IntType i2(i);
|
||||||
|
new(&aux_vect[i])IntPairType(boost::move(i1), boost::move(i2));
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < MaxElem; ++i) {
|
||||||
|
boostmap[boost::move(aux_vect[i].first)] = boost::move(aux_vect[i].second);
|
||||||
|
stdmap[i] = i;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!CheckEqualPairContainers(boostmap, stdmap)) return 1;
|
||||||
|
if (!CheckEqualPairContainers(boostmultimap, stdmultimap)) return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class MyBoostMap
|
||||||
|
, class MyStdMap
|
||||||
|
, class MyBoostMultiMap
|
||||||
|
, class MyStdMultiMap>
|
||||||
|
int map_test_indexing_copyable(MyBoostMap& boostmap, MyStdMap& stdmap, MyBoostMultiMap& boostmultimap, MyStdMultiMap& stdmultimap, boost::container::dtl::true_type)
|
||||||
|
{
|
||||||
|
typedef typename MyBoostMap::key_type IntType;
|
||||||
|
typedef dtl::pair<IntType, IntType> IntPairType;
|
||||||
|
|
||||||
|
{ //operator[] test
|
||||||
|
boostmap.clear();
|
||||||
|
boostmultimap.clear();
|
||||||
|
stdmap.clear();
|
||||||
|
stdmultimap.clear();
|
||||||
|
|
||||||
|
IntPairType aux_vect[(std::size_t)MaxElem];
|
||||||
|
for (int i = 0; i < MaxElem; ++i) {
|
||||||
|
IntType i1(i);
|
||||||
|
IntType i2(i);
|
||||||
|
new(&aux_vect[i])IntPairType(boost::move(i1), boost::move(i2));
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < MaxElem; ++i) {
|
||||||
|
boostmap[aux_vect[i].first] = boost::move(aux_vect[i].second);
|
||||||
|
stdmap[i] = i;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!CheckEqualPairContainers(boostmap, stdmap)) return 1;
|
||||||
|
if (!CheckEqualPairContainers(boostmultimap, stdmultimap)) return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class MyBoostMap
|
||||||
|
, class MyStdMap
|
||||||
|
, class MyBoostMultiMap
|
||||||
|
, class MyStdMultiMap>
|
||||||
|
int map_test_indexing_move_assignable(MyBoostMap& , MyStdMap& , MyBoostMultiMap& , MyStdMultiMap&, boost::container::dtl::false_type)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class MyBoostMap
|
||||||
|
, class MyStdMap
|
||||||
|
, class MyBoostMultiMap
|
||||||
|
, class MyStdMultiMap>
|
||||||
|
int map_test_indexing_copyable(MyBoostMap&, MyStdMap&, MyBoostMultiMap&, MyStdMultiMap&, boost::container::dtl::false_type)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
template< class MyBoostMap, class StdMap, class MaybeMove>
|
template< class MyBoostMap, class StdMap, class MaybeMove>
|
||||||
int map_test_insert_or_assign_impl()
|
int map_test_insert_or_assign_impl()
|
||||||
{
|
{
|
||||||
@@ -1252,7 +1337,10 @@ int map_test()
|
|||||||
if (map_test_search(boostmap, stdmap, boostmultimap, stdmultimap))
|
if (map_test_search(boostmap, stdmap, boostmultimap, stdmultimap))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
if (map_test_indexing(boostmap, stdmap, boostmultimap, stdmultimap))
|
if (map_test_indexing_move_assignable(boostmap, stdmap, boostmultimap, stdmultimap, move_assignable_t()))
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
if (map_test_indexing_copyable(boostmap, stdmap, boostmultimap, stdmultimap, copyable_t()))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
if (map_test_try_emplace(boostmap, stdmap, boostmultimap, stdmultimap))
|
if (map_test_try_emplace(boostmap, stdmap, boostmultimap, stdmultimap))
|
||||||
|
Reference in New Issue
Block a user