From e8baf848bc426022dffbc814db8e1261d6033d4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= Date: Wed, 21 May 2025 12:05:35 +0200 Subject: [PATCH] Fixes #250 ("Custom container leads to "invalid use of incomplete type" for "struct boost::container::dtl::container_rebind"") --- doc/container.qbk | 7 +++++++ include/boost/container/flat_map.hpp | 13 ++++++++++++- test/flat_map_adaptor_test.cpp | 10 ++++++++++ 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/doc/container.qbk b/doc/container.qbk index f0ada5a..7b1889b 100644 --- a/doc/container.qbk +++ b/doc/container.qbk @@ -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: diff --git a/include/boost/container/flat_map.hpp b/include/boost/container/flat_map.hpp index 8ec402c..dc64d92 100644 --- a/include/boost/container/flat_map.hpp +++ b/include/boost/container/flat_map.hpp @@ -30,7 +30,6 @@ #include #include #include //equal() -#include #include // move #include @@ -54,6 +53,10 @@ #define BOOST_CONTAINER_STD_PAIR_IS_MOVABLE #endif +#ifndef BOOST_CONTAINER_STD_PAIR_IS_MOVABLE +#include +#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 struct has_trivial_destructor_after_move > { typedef typename boost::container::flat_map::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::type alloc_or_cont_t; + #endif typedef ::boost::container::dtl::flat_tree, Compare, alloc_or_cont_t> tree; BOOST_STATIC_CONSTEXPR bool value = ::boost::has_trivial_destructor_after_move::value; }; @@ -3143,7 +3150,11 @@ template struct has_trivial_destructor_after_move< boost::container::flat_multimap > { typedef typename boost::container::flat_multimap::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::type alloc_or_cont_t; + #endif typedef ::boost::container::dtl::flat_tree, Compare, alloc_or_cont_t> tree; BOOST_STATIC_CONSTEXPR bool value = ::boost::has_trivial_destructor_after_move::value; }; diff --git a/test/flat_map_adaptor_test.cpp b/test/flat_map_adaptor_test.cpp index 62b0134..94f6a64 100644 --- a/test/flat_map_adaptor_test.cpp +++ b/test/flat_map_adaptor_test.cpp @@ -15,7 +15,9 @@ #include #include +#ifndef BOOST_CONTAINER_STD_PAIR_IS_MOVABLE #include +#endif #include "flat_map_test.hpp" #include @@ -32,13 +34,21 @@ struct GetMapContainer typedef flat_map< ValueType , ValueType , std::less + #ifdef BOOST_CONTAINER_STD_PAIR_IS_MOVABLE + , VoidAllocatorOrContainer + #else , typename boost::container::dtl::container_or_allocator_rebind::type + #endif > map_type; typedef flat_multimap< ValueType , ValueType , std::less + #ifdef BOOST_CONTAINER_STD_PAIR_IS_MOVABLE + , VoidAllocatorOrContainer + #else , typename boost::container::dtl::container_or_allocator_rebind::type + #endif > multimap_type; }; };