container
container copied to clipboard
Custom container leads to "invalid use of incomplete type" for "struct boost::container::dtl::container_rebind"
In our project we have custom container (let's call it CustomContainer
) that doesn't match boost::container::dtl::container_rebind
specializations in the include/boost/container/detail/container_rebind.hpp
file.
Such a container is used in flat_map
the following way:
template<typename T, std::size_t size>
class CustomContainer;
constexpr std::uint8_t size{...};
using FlatMapType = boost::container::flat_map<
KeyType,
MappedType,
std::less<>,
CustomContainer<std::pair<KeyType, MappedType>, size>>;
And with GCC 10.2 and Boost 1.79 we are getting compilation errors:
{prefix}/usr/include/boost/container/detail/container_or_allocator_rebind.hpp:30:8: error: invalid use of incomplete type 'struct boost::container::dtl::container_rebind<CustomContainer<std::pair<KeyType, MappedType>, {size}>>, boost::container::dtl::pair<KeyType, MappedType> >'
30 | struct container_or_allocator_rebind_impl
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
I have reproduced the same on Compiler Explorer: https://godbolt.org/z/eGTsYer6r. It seems to apply still in Boost 1.82 as well.
My guess would be we need to provide container_rebind
specialization for our container. It does seem to work.
However, container_rebind
is not documented as an extension point. Furthermore, it is introduced by a header in detail/
subdirectory, making it even more uneasy to tweak with it in the user code.