Fixes #164 ("Compile error when using pmr::map with a std::pair; works when using a std::tuple")

This commit is contained in:
Ion Gaztañaga
2020-11-13 23:43:02 +01:00
parent 0b59dadd8b
commit ae93df82ea
2 changed files with 19 additions and 18 deletions

View File

@@ -1343,6 +1343,7 @@ use [*Boost.Container]? There are several reasons for that:
* Added [[no-discard]] attribute in all containers to catch bugs related to unused return values. * Added [[no-discard]] attribute in all containers to catch bugs related to unused return values.
* Fixed bugs/issues: * Fixed bugs/issues:
* [@https://github.com/boostorg/container/issues/171 GitHub #171: ['"deque::clear() uses undefined behaviour"]]. * [@https://github.com/boostorg/container/issues/171 GitHub #171: ['"deque::clear() uses undefined behaviour"]].
* [@https://github.com/boostorg/container/issues/164 GitHub #164: ['"Compile error when using `pmr::map` with a `std::pair`; works when using a `std::tuple`"]].
[endsect] [endsect]

View File

@@ -225,9 +225,9 @@ BOOST_CONTAINER_DOC1ST(void, typename dtl::enable_if<dtl::is_pair<Pair> BOOST_MO
, BOOST_FWD_REF(ArgAlloc) arg_alloc , BOOST_FWD_REF(ArgAlloc) arg_alloc
, Pair* p) , Pair* p)
{ {
(dispatch_uses_allocator)(construct_alloc, arg_alloc, dtl::addressof(p->first)); dispatch_uses_allocator(construct_alloc, arg_alloc, dtl::addressof(p->first));
BOOST_TRY{ BOOST_TRY{
(dispatch_uses_allocator)(construct_alloc, arg_alloc, dtl::addressof(p->second)); dispatch_uses_allocator(construct_alloc, arg_alloc, dtl::addressof(p->second));
} }
BOOST_CATCH(...) { BOOST_CATCH(...) {
allocator_traits<ConstructAlloc>::destroy(construct_alloc, dtl::addressof(p->first)); allocator_traits<ConstructAlloc>::destroy(construct_alloc, dtl::addressof(p->first));
@@ -246,9 +246,9 @@ BOOST_CONTAINER_DOC1ST(void, typename dtl::enable_if<dtl::is_pair<Pair> BOOST_MO
, BOOST_FWD_REF(ArgAlloc) arg_alloc , BOOST_FWD_REF(ArgAlloc) arg_alloc
, Pair* p, BOOST_FWD_REF(U) x, BOOST_FWD_REF(V) y) , Pair* p, BOOST_FWD_REF(U) x, BOOST_FWD_REF(V) y)
{ {
(dispatch_uses_allocator)(construct_alloc, arg_alloc, dtl::addressof(p->first), ::boost::forward<U>(x)); dispatch_uses_allocator(construct_alloc, arg_alloc, dtl::addressof(p->first), ::boost::forward<U>(x));
BOOST_TRY{ BOOST_TRY{
(dispatch_uses_allocator)(construct_alloc, arg_alloc, dtl::addressof(p->second), ::boost::forward<V>(y)); dispatch_uses_allocator(construct_alloc, arg_alloc, dtl::addressof(p->second), ::boost::forward<V>(y));
} }
BOOST_CATCH(...){ BOOST_CATCH(...){
allocator_traits<ConstructAlloc>::destroy(construct_alloc, dtl::addressof(p->first)); allocator_traits<ConstructAlloc>::destroy(construct_alloc, dtl::addressof(p->first));
@@ -265,7 +265,7 @@ BOOST_CONTAINER_DOC1ST(void, typename dtl::enable_if< dtl::is_pair<Pair> BOOST_M
(ConstructAlloc & construct_alloc (ConstructAlloc & construct_alloc
, BOOST_FWD_REF(ArgAlloc) arg_alloc , BOOST_FWD_REF(ArgAlloc) arg_alloc
, Pair* p, Pair2& x) , Pair* p, Pair2& x)
{ (dispatch_uses_allocator)(construct_alloc, arg_alloc, p, x.first, x.second); } { dispatch_uses_allocator(construct_alloc, arg_alloc, p, x.first, x.second); }
template < typename ConstructAlloc template < typename ConstructAlloc
, typename ArgAlloc , typename ArgAlloc
@@ -278,7 +278,7 @@ typename dtl::enable_if_and
(ConstructAlloc & construct_alloc (ConstructAlloc & construct_alloc
, BOOST_FWD_REF(ArgAlloc) arg_alloc , BOOST_FWD_REF(ArgAlloc) arg_alloc
, Pair* p, BOOST_RV_REF_BEG Pair2 BOOST_RV_REF_END x) , Pair* p, BOOST_RV_REF_BEG Pair2 BOOST_RV_REF_END x)
{ (dispatch_uses_allocator)(construct_alloc, arg_alloc, p, ::boost::move(x.first), ::boost::move(x.second)); } { dispatch_uses_allocator(construct_alloc, arg_alloc, p, ::boost::move(x.first), ::boost::move(x.second)); }
//piecewise construction from boost::tuple //piecewise construction from boost::tuple
@@ -292,10 +292,10 @@ typename dtl::enable_if< dtl::is_pair<Pair> BOOST_MOVE_I void>::type\
, BoostTuple<BOOST_MOVE_TARGQ##M BOOST_MOVE_I##M BOOST_MOVE_REPEAT(BOOST_MOVE_SUB(10,M),::boost::tuples::null_type)> q)\ , BoostTuple<BOOST_MOVE_TARGQ##M BOOST_MOVE_I##M BOOST_MOVE_REPEAT(BOOST_MOVE_SUB(10,M),::boost::tuples::null_type)> q)\
{\ {\
(void)p; (void)q;\ (void)p; (void)q;\
(dispatch_uses_allocator)\ dispatch_uses_allocator\
(construct_alloc, arg_alloc, dtl::addressof(pair->first) BOOST_MOVE_I_IF(N) BOOST_MOVE_TMPL_GET##N);\ (construct_alloc, arg_alloc, dtl::addressof(pair->first) BOOST_MOVE_I_IF(N) BOOST_MOVE_TMPL_GET##N);\
BOOST_TRY{\ BOOST_TRY{\
(dispatch_uses_allocator)\ dispatch_uses_allocator\
(construct_alloc, arg_alloc, dtl::addressof(pair->second) BOOST_MOVE_I_IF(M) BOOST_MOVE_TMPL_GETQ##M);\ (construct_alloc, arg_alloc, dtl::addressof(pair->second) BOOST_MOVE_I_IF(M) BOOST_MOVE_TMPL_GETQ##M);\
}\ }\
BOOST_CATCH(...) {\ BOOST_CATCH(...) {\
@@ -317,9 +317,9 @@ BOOST_MOVE_ITER2D_0TOMAX(9, BOOST_DISPATCH_USES_ALLOCATOR_PIECEWISE_CONSTRUCT_BO
, Tuple<Args1...>& t1, Tuple<Args2...>& t2, index_tuple<Indexes1...>, index_tuple<Indexes2...>) , Tuple<Args1...>& t1, Tuple<Args2...>& t2, index_tuple<Indexes1...>, index_tuple<Indexes2...>)
{ {
(void)t1; (void)t2; (void)t1; (void)t2;
(dispatch_uses_allocator)(construct_alloc, arg_alloc, dtl::addressof(pair->first), ::boost::forward<Args1>(get<Indexes1>(t1))...); dispatch_uses_allocator(construct_alloc, arg_alloc, dtl::addressof(pair->first), ::boost::forward<Args1>(get<Indexes1>(t1))...);
BOOST_TRY{ BOOST_TRY{
(dispatch_uses_allocator)(construct_alloc, arg_alloc, dtl::addressof(pair->second), ::boost::forward<Args2>(get<Indexes2>(t2))...); dispatch_uses_allocator(construct_alloc, arg_alloc, dtl::addressof(pair->second), ::boost::forward<Args2>(get<Indexes2>(t2))...);
} }
BOOST_CATCH(...){ BOOST_CATCH(...){
allocator_traits<ConstructAlloc>::destroy(construct_alloc, dtl::addressof(pair->first)); allocator_traits<ConstructAlloc>::destroy(construct_alloc, dtl::addressof(pair->first));
@@ -352,10 +352,10 @@ BOOST_MOVE_ITER2D_0TOMAX(9, BOOST_DISPATCH_USES_ALLOCATOR_PIECEWISE_CONSTRUCT_BO
, StdTuple<BOOST_MOVE_TARGQ##M BOOST_MOVE_I##M BOOST_MOVE_REPEAT(BOOST_MOVE_SUB(10,M),::std::tr1::_Nil)> q)\ , StdTuple<BOOST_MOVE_TARGQ##M BOOST_MOVE_I##M BOOST_MOVE_REPEAT(BOOST_MOVE_SUB(10,M),::std::tr1::_Nil)> q)\
{\ {\
(void)p; (void)q;\ (void)p; (void)q;\
(dispatch_uses_allocator)\ dispatch_uses_allocator\
(construct_alloc, arg_alloc, dtl::addressof(pair->first) BOOST_MOVE_I_IF(N) BOOST_MOVE_GET_IDX##N);\ (construct_alloc, arg_alloc, dtl::addressof(pair->first) BOOST_MOVE_I_IF(N) BOOST_MOVE_GET_IDX##N);\
BOOST_TRY{\ BOOST_TRY{\
(dispatch_uses_allocator)\ dispatch_uses_allocator\
(construct_alloc, arg_alloc, dtl::addressof(pair->second) BOOST_MOVE_I_IF(M) BOOST_MOVE_GET_IDXQ##M);\ (construct_alloc, arg_alloc, dtl::addressof(pair->second) BOOST_MOVE_I_IF(M) BOOST_MOVE_GET_IDXQ##M);\
}\ }\
BOOST_CATCH(...) {\ BOOST_CATCH(...) {\
@@ -387,10 +387,10 @@ BOOST_MOVE_ITER2D_0TOMAX(9, BOOST_DISPATCH_USES_ALLOCATOR_PIECEWISE_CONSTRUCT_BO
, StdTuple<BOOST_MOVE_TARGQ##M BOOST_MOVE_I##M BOOST_MOVE_REPEAT(BOOST_MOVE_SUB(BOOST_MOVE_ADD(_VARIADIC_MAX, 3),M),::std::_Nil) > q)\ , StdTuple<BOOST_MOVE_TARGQ##M BOOST_MOVE_I##M BOOST_MOVE_REPEAT(BOOST_MOVE_SUB(BOOST_MOVE_ADD(_VARIADIC_MAX, 3),M),::std::_Nil) > q)\
{\ {\
(void)p; (void)q;\ (void)p; (void)q;\
(dispatch_uses_allocator)\ dispatch_uses_allocator\
(construct_alloc, arg_alloc, dtl::addressof(pair->first) BOOST_MOVE_I_IF(N) BOOST_MOVE_GET_IDX##N);\ (construct_alloc, arg_alloc, dtl::addressof(pair->first) BOOST_MOVE_I_IF(N) BOOST_MOVE_GET_IDX##N);\
BOOST_TRY{\ BOOST_TRY{\
(dispatch_uses_allocator)\ dispatch_uses_allocator\
(construct_alloc, arg_alloc, dtl::addressof(pair->second) BOOST_MOVE_I_IF(M) BOOST_MOVE_GET_IDXQ##M);\ (construct_alloc, arg_alloc, dtl::addressof(pair->second) BOOST_MOVE_I_IF(M) BOOST_MOVE_GET_IDXQ##M);\
}\ }\
BOOST_CATCH(...) {\ BOOST_CATCH(...) {\
@@ -415,9 +415,9 @@ typename dtl::enable_if< dtl::is_pair<Pair>, void >::type
dispatch_uses_allocator dispatch_uses_allocator
(ConstructAlloc & construct_alloc, BOOST_FWD_REF(ArgAlloc) arg_alloc, Pair* p, try_emplace_t, BOOST_FWD_REF(KeyType) k, BOOST_FWD_REF(Args) ...args) (ConstructAlloc & construct_alloc, BOOST_FWD_REF(ArgAlloc) arg_alloc, Pair* p, try_emplace_t, BOOST_FWD_REF(KeyType) k, BOOST_FWD_REF(Args) ...args)
{ {
(dispatch_uses_allocator)(construct_alloc, arg_alloc, dtl::addressof(p->first), ::boost::forward<KeyType>(k)); dispatch_uses_allocator(construct_alloc, arg_alloc, dtl::addressof(p->first), ::boost::forward<KeyType>(k));
BOOST_TRY{ BOOST_TRY{
(dispatch_uses_allocator)(construct_alloc, arg_alloc, dtl::addressof(p->second), ::boost::forward<Args>(args)...); dispatch_uses_allocator(construct_alloc, arg_alloc, dtl::addressof(p->second), ::boost::forward<Args>(args)...);
} }
BOOST_CATCH(...) { BOOST_CATCH(...) {
allocator_traits<ConstructAlloc>::destroy(construct_alloc, dtl::addressof(p->first)); allocator_traits<ConstructAlloc>::destroy(construct_alloc, dtl::addressof(p->first));
@@ -436,9 +436,9 @@ typename dtl::enable_if< dtl::is_pair<Pair>, void >::type
(ConstructAlloc &construct_alloc, BOOST_FWD_REF(ArgAlloc) arg_alloc, Pair* p, try_emplace_t, \ (ConstructAlloc &construct_alloc, BOOST_FWD_REF(ArgAlloc) arg_alloc, Pair* p, try_emplace_t, \
BOOST_FWD_REF(KeyType) k BOOST_MOVE_I##N BOOST_MOVE_UREF##N)\ BOOST_FWD_REF(KeyType) k BOOST_MOVE_I##N BOOST_MOVE_UREF##N)\
{\ {\
(dispatch_uses_allocator)(construct_alloc, arg_alloc, dtl::addressof(p->first), ::boost::forward<KeyType>(k));\ dispatch_uses_allocator(construct_alloc, arg_alloc, dtl::addressof(p->first), ::boost::forward<KeyType>(k));\
BOOST_TRY{\ BOOST_TRY{\
(dispatch_uses_allocator)(construct_alloc, arg_alloc, dtl::addressof(p->second) BOOST_MOVE_I##N BOOST_MOVE_FWD##N);\ dispatch_uses_allocator(construct_alloc, arg_alloc, dtl::addressof(p->second) BOOST_MOVE_I##N BOOST_MOVE_FWD##N);\
}\ }\
BOOST_CATCH(...) {\ BOOST_CATCH(...) {\
allocator_traits<ConstructAlloc>::destroy(construct_alloc, dtl::addressof(p->first));\ allocator_traits<ConstructAlloc>::destroy(construct_alloc, dtl::addressof(p->first));\