Skip to content

Commit e8baf84

Browse files
committed
Fixes #250 ("Custom container leads to "invalid use of incomplete type" for "struct boost::container::dtl::container_rebind"")
1 parent aa4b215 commit e8baf84

File tree

3 files changed

+29
-1
lines changed

3 files changed

+29
-1
lines changed

doc/container.qbk

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1421,6 +1421,13 @@ use [*Boost.Container]? There are several reasons for that:
14211421

14221422
[section:release_notes Release Notes]
14231423

1424+
[section:release_notes_boost_1_89_00 Boost 1.89 Release]
1425+
1426+
* Fixed bugs/issues:
1427+
* [@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"]].
1428+
1429+
[endsect]
1430+
14241431
[section:release_notes_boost_1_88_00 Boost 1.88 Release]
14251432

14261433
* Fixed bugs/issues:

include/boost/container/flat_map.hpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
#include <boost/container/detail/type_traits.hpp>
3131
#include <boost/container/detail/mpl.hpp>
3232
#include <boost/container/detail/algorithm.hpp> //equal()
33-
#include <boost/container/detail/container_or_allocator_rebind.hpp>
3433
#include <boost/container/detail/pair.hpp>
3534
// move
3635
#include <boost/move/utility_core.hpp>
@@ -54,6 +53,10 @@
5453
#define BOOST_CONTAINER_STD_PAIR_IS_MOVABLE
5554
#endif
5655

56+
#ifndef BOOST_CONTAINER_STD_PAIR_IS_MOVABLE
57+
#include <boost/container/detail/container_or_allocator_rebind.hpp>
58+
#endif
59+
5760
//for C++03 compilers, were type-puning is the only option for std::pair
5861
//disable strict aliasing to reduce problems.
5962
#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>
17881791
struct has_trivial_destructor_after_move<boost::container::flat_map<Key, T, Compare, AllocatorOrContainer> >
17891792
{
17901793
typedef typename boost::container::flat_map<Key, T, Compare, AllocatorOrContainer>::value_type value_t;
1794+
#ifdef BOOST_CONTAINER_STD_PAIR_IS_MOVABLE
1795+
typedef AllocatorOrContainer alloc_or_cont_t;
1796+
#else
17911797
typedef typename ::boost::container::dtl::container_or_allocator_rebind<AllocatorOrContainer, value_t>::type alloc_or_cont_t;
1798+
#endif
17921799
typedef ::boost::container::dtl::flat_tree<value_t,::boost::container::dtl::select1st<Key>, Compare, alloc_or_cont_t> tree;
17931800
BOOST_STATIC_CONSTEXPR bool value = ::boost::has_trivial_destructor_after_move<tree>::value;
17941801
};
@@ -3143,7 +3150,11 @@ template <class Key, class T, class Compare, class AllocatorOrContainer>
31433150
struct has_trivial_destructor_after_move< boost::container::flat_multimap<Key, T, Compare, AllocatorOrContainer> >
31443151
{
31453152
typedef typename boost::container::flat_multimap<Key, T, Compare, AllocatorOrContainer>::value_type value_t;
3153+
#ifdef BOOST_CONTAINER_STD_PAIR_IS_MOVABLE
3154+
typedef AllocatorOrContainer alloc_or_cont_t;
3155+
#else
31463156
typedef typename ::boost::container::dtl::container_or_allocator_rebind<AllocatorOrContainer, value_t>::type alloc_or_cont_t;
3157+
#endif
31473158
typedef ::boost::container::dtl::flat_tree<value_t,::boost::container::dtl::select1st<Key>, Compare, alloc_or_cont_t> tree;
31483159
BOOST_STATIC_CONSTEXPR bool value = ::boost::has_trivial_destructor_after_move<tree>::value;
31493160
};

test/flat_map_adaptor_test.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@
1515
#include <boost/container/devector.hpp>
1616
#include <boost/container/deque.hpp>
1717

18+
#ifndef BOOST_CONTAINER_STD_PAIR_IS_MOVABLE
1819
#include <boost/container/detail/container_or_allocator_rebind.hpp>
20+
#endif
1921

2022
#include "flat_map_test.hpp"
2123
#include <map>
@@ -32,13 +34,21 @@ struct GetMapContainer
3234
typedef flat_map< ValueType
3335
, ValueType
3436
, std::less<ValueType>
37+
#ifdef BOOST_CONTAINER_STD_PAIR_IS_MOVABLE
38+
, VoidAllocatorOrContainer
39+
#else
3540
, typename boost::container::dtl::container_or_allocator_rebind<VoidAllocatorOrContainer, type_t>::type
41+
#endif
3642
> map_type;
3743

3844
typedef flat_multimap< ValueType
3945
, ValueType
4046
, std::less<ValueType>
47+
#ifdef BOOST_CONTAINER_STD_PAIR_IS_MOVABLE
48+
, VoidAllocatorOrContainer
49+
#else
4150
, typename boost::container::dtl::container_or_allocator_rebind<VoidAllocatorOrContainer, type_t>::type
51+
#endif
4252
> multimap_type;
4353
};
4454
};

0 commit comments

Comments
 (0)