boostorg / container

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

polymorphic_allocator's copy special member functions are not noexcept #180

Closed palebedev closed 3 years ago

palebedev commented 3 years ago

The following fails:

#include <boost/asio/execution/allocator.hpp>
#include <boost/asio/query.hpp>
#include <boost/asio/require.hpp>
#include <boost/asio/system_executor.hpp>
#include <boost/container/pmr/polymorphic_allocator.hpp>

using my_allocator_t = boost::container::pmr::polymorphic_allocator<char>;
using executor_t = boost::asio::require_result<
    boost::asio::system_executor,
    boost::asio::execution::allocator_t<my_allocator_t>
>::type;
static_assert(std::is_same_v<
    boost::asio::query_result<
        executor_t,
        boost::asio::execution::allocator_t<void>
    >::type,
    my_allocator_t
>);

This happens because:

While many "Throws: Nothing." functions are not noexcept at the language level for various reasons, I believe ASIO has the right to check this property formally on special member functions. Copy constructor/assignment functions in boost::container::polymorphic_allocator should either be marked BOOST_NOEXCEPT or removed altogether (which would also make them trivial). I don't know whether changing their triviality could be a problem and where their docs should go if they were removed.

igaztanaga commented 3 years ago

Many thanks for the report!