mirror of
https://github.com/boostorg/container.git
synced 2025-08-01 21:44:27 +02:00
Fixed GitHub #98: ("flat_map: insert_or_assign does not work with hint")
This commit is contained in:
@@ -1248,6 +1248,7 @@ use [*Boost.Container]? There are several reasons for that:
|
||||
* Fixed bugs:
|
||||
* [@https://github.com/boostorg/container/pull/96 GitHub #96: ['"Workaround: Intel compilers do not offer CTAD yet"]].
|
||||
* [@https://github.com/boostorg/container/issues/97 GitHub #97: ['"buffer overflow in boost::container::flat_map on FreeBSD"]].
|
||||
* [@https://github.com/boostorg/container/issues/98 GitHub #98: ['"flat_map: insert_or_assign does not work with hint"]].
|
||||
* [@https://github.com/boostorg/container/issues/100 GitHub #100: ['"Compile error on Green Hills: container_detail::flat_tree has no member insert"]].
|
||||
|
||||
[endsect]
|
||||
|
@@ -788,7 +788,7 @@ class flat_map
|
||||
//! Complexity: Logarithmic in the size of the container in general, but amortized constant if
|
||||
//! the new element is inserted just before hint.
|
||||
template <class M>
|
||||
BOOST_CONTAINER_FORCEINLINE iterator insert_or_assign(const_iterator hint, const key_type& k, BOOST_FWD_REF(M) obj)
|
||||
BOOST_CONTAINER_FORCEINLINE std::pair<iterator, bool> insert_or_assign(const_iterator hint, const key_type& k, BOOST_FWD_REF(M) obj)
|
||||
{
|
||||
return dtl::force_copy< std::pair<iterator, bool> >
|
||||
(this->m_flat_tree.insert_or_assign
|
||||
@@ -812,7 +812,7 @@ class flat_map
|
||||
//! Complexity: Logarithmic in the size of the container in general, but amortized constant if
|
||||
//! the new element is inserted just before hint.
|
||||
template <class M>
|
||||
BOOST_CONTAINER_FORCEINLINE iterator insert_or_assign(const_iterator hint, BOOST_RV_REF(key_type) k, BOOST_FWD_REF(M) obj)
|
||||
BOOST_CONTAINER_FORCEINLINE std::pair<iterator, bool> insert_or_assign(const_iterator hint, BOOST_RV_REF(key_type) k, BOOST_FWD_REF(M) obj)
|
||||
{
|
||||
return dtl::force_copy< std::pair<iterator, bool> >
|
||||
(this->m_flat_tree.insert_or_assign
|
||||
|
@@ -464,11 +464,27 @@ bool test_heterogeneous_lookups()
|
||||
const map_t &cmap1 = map1;
|
||||
const mmap_t &cmmap1 = mmap1;
|
||||
|
||||
map1.insert_or_assign(1, 'a');
|
||||
map1.insert_or_assign(1, 'b');
|
||||
map1.insert_or_assign(2, 'c');
|
||||
map1.insert_or_assign(2, 'd');
|
||||
map1.insert_or_assign(3, 'e');
|
||||
if(!map1.insert_or_assign(1, 'a').second)
|
||||
return false;
|
||||
if( map1.insert_or_assign(1, 'b').second)
|
||||
return false;
|
||||
if(!map1.insert_or_assign(2, 'c').second)
|
||||
return false;
|
||||
if( map1.insert_or_assign(2, 'd').second)
|
||||
return false;
|
||||
if(!map1.insert_or_assign(3, 'e').second)
|
||||
return false;
|
||||
|
||||
if(map1.insert_or_assign(1, 'a').second)
|
||||
return false;
|
||||
if(map1.insert_or_assign(1, 'b').second)
|
||||
return false;
|
||||
if(map1.insert_or_assign(2, 'c').second)
|
||||
return false;
|
||||
if(map1.insert_or_assign(2, 'd').second)
|
||||
return false;
|
||||
if(map1.insert_or_assign(3, 'e').second)
|
||||
return false;
|
||||
|
||||
mmap1.insert(value_type(1, 'a'));
|
||||
mmap1.insert(value_type(1, 'b'));
|
||||
|
@@ -260,11 +260,27 @@ bool test_heterogeneous_lookups()
|
||||
const map_t &cmap1 = map1;
|
||||
const mmap_t &cmmap1 = mmap1;
|
||||
|
||||
map1.insert_or_assign(1, 'a');
|
||||
map1.insert_or_assign(1, 'b');
|
||||
map1.insert_or_assign(2, 'c');
|
||||
map1.insert_or_assign(2, 'd');
|
||||
map1.insert_or_assign(3, 'e');
|
||||
if(!map1.insert_or_assign(1, 'a').second)
|
||||
return false;
|
||||
if( map1.insert_or_assign(1, 'b').second)
|
||||
return false;
|
||||
if(!map1.insert_or_assign(2, 'c').second)
|
||||
return false;
|
||||
if( map1.insert_or_assign(2, 'd').second)
|
||||
return false;
|
||||
if(!map1.insert_or_assign(3, 'e').second)
|
||||
return false;
|
||||
|
||||
if(map1.insert_or_assign(1, 'a').second)
|
||||
return false;
|
||||
if(map1.insert_or_assign(1, 'b').second)
|
||||
return false;
|
||||
if(map1.insert_or_assign(2, 'c').second)
|
||||
return false;
|
||||
if(map1.insert_or_assign(2, 'd').second)
|
||||
return false;
|
||||
if(map1.insert_or_assign(3, 'e').second)
|
||||
return false;
|
||||
|
||||
mmap1.insert(value_type(1, 'a'));
|
||||
mmap1.insert(value_type(1, 'b'));
|
||||
|
Reference in New Issue
Block a user