Fixes #250 ("Custom container leads to "invalid use of incomplete type" for "struct boost::container::dtl::container_rebind"")

This commit is contained in:
Ion Gaztañaga
2025-05-21 12:05:35 +02:00
parent aa4b215681
commit e8baf848bc
3 changed files with 29 additions and 1 deletions

View File

@ -1421,6 +1421,13 @@ use [*Boost.Container]? There are several reasons for that:
[section:release_notes Release Notes]
[section:release_notes_boost_1_89_00 Boost 1.89 Release]
* Fixed bugs/issues:
* [@https://github.com/boostorg/container/issues/250 GitHub #250: ['"Custom container leads to invalid use of incomplete type for struct boost::container::dtl::container_rebind"]].
[endsect]
[section:release_notes_boost_1_88_00 Boost 1.88 Release]
* Fixed bugs/issues:

View File

@ -30,7 +30,6 @@
#include <boost/container/detail/type_traits.hpp>
#include <boost/container/detail/mpl.hpp>
#include <boost/container/detail/algorithm.hpp> //equal()
#include <boost/container/detail/container_or_allocator_rebind.hpp>
#include <boost/container/detail/pair.hpp>
// move
#include <boost/move/utility_core.hpp>
@ -54,6 +53,10 @@
#define BOOST_CONTAINER_STD_PAIR_IS_MOVABLE
#endif
#ifndef BOOST_CONTAINER_STD_PAIR_IS_MOVABLE
#include <boost/container/detail/container_or_allocator_rebind.hpp>
#endif
//for C++03 compilers, were type-puning is the only option for std::pair
//disable strict aliasing to reduce problems.
#if defined(BOOST_GCC) && (BOOST_GCC >= 100000) && !defined(BOOST_CONTAINER_STD_PAIR_IS_MOVABLE)
@ -1788,7 +1791,11 @@ template <class Key, class T, class Compare, class AllocatorOrContainer>
struct has_trivial_destructor_after_move<boost::container::flat_map<Key, T, Compare, AllocatorOrContainer> >
{
typedef typename boost::container::flat_map<Key, T, Compare, AllocatorOrContainer>::value_type value_t;
#ifdef BOOST_CONTAINER_STD_PAIR_IS_MOVABLE
typedef AllocatorOrContainer alloc_or_cont_t;
#else
typedef typename ::boost::container::dtl::container_or_allocator_rebind<AllocatorOrContainer, value_t>::type alloc_or_cont_t;
#endif
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;
};
@ -3143,7 +3150,11 @@ template <class Key, class T, class Compare, class AllocatorOrContainer>
struct has_trivial_destructor_after_move< boost::container::flat_multimap<Key, T, Compare, AllocatorOrContainer> >
{
typedef typename boost::container::flat_multimap<Key, T, Compare, AllocatorOrContainer>::value_type value_t;
#ifdef BOOST_CONTAINER_STD_PAIR_IS_MOVABLE
typedef AllocatorOrContainer alloc_or_cont_t;
#else
typedef typename ::boost::container::dtl::container_or_allocator_rebind<AllocatorOrContainer, value_t>::type alloc_or_cont_t;
#endif
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;
};

View File

@ -15,7 +15,9 @@
#include <boost/container/devector.hpp>
#include <boost/container/deque.hpp>
#ifndef BOOST_CONTAINER_STD_PAIR_IS_MOVABLE
#include <boost/container/detail/container_or_allocator_rebind.hpp>
#endif
#include "flat_map_test.hpp"
#include <map>
@ -32,13 +34,21 @@ struct GetMapContainer
typedef flat_map< ValueType
, ValueType
, std::less<ValueType>
#ifdef BOOST_CONTAINER_STD_PAIR_IS_MOVABLE
, VoidAllocatorOrContainer
#else
, typename boost::container::dtl::container_or_allocator_rebind<VoidAllocatorOrContainer, type_t>::type
#endif
> map_type;
typedef flat_multimap< ValueType
, ValueType
, std::less<ValueType>
#ifdef BOOST_CONTAINER_STD_PAIR_IS_MOVABLE
, VoidAllocatorOrContainer
#else
, typename boost::container::dtl::container_or_allocator_rebind<VoidAllocatorOrContainer, type_t>::type
#endif
> multimap_type;
};
};