boostorg / container

STL-like containers from Boost
http://www.boost.org/libs/container/
Boost Software License 1.0
96 stars 116 forks source link

Usage of uses_allocator needs a remove_cvref_t #160

Closed vinniefalco closed 3 years ago

vinniefalco commented 3 years ago

This specialization of boost::container::uses_allocator:

template<class T>
struct uses_allocator<
    ::boost::json::value,
    json::polymorphic_allocator<T>>
        : std::true_type
{
};

fails, because Boost.Container does not use remove_cvref on the allocator. This causes uses_allocator to receive json::polymorphic_allocator<T>&

However if I use this workaround:

template<class T>
struct uses_allocator<
    ::boost::json::value,
    json::polymorphic_allocator<T>& > // <---- note the reference
        : std::true_type
{
};

it works correctly. The problem is here (and is likely in other places). I believe remove_cvref_t<ArgAlloc> is needed: https://github.com/boostorg/container/blob/5a52472cd00994bf1752e92c1c178a5a822a36cb/include/boost/container/detail/dispatch_uses_allocator.hpp#L116

igaztanaga commented 3 years ago

Thanks for the report!