chriskohlhoff / asio

Asio C++ Library
http://think-async.com/Asio
4.88k stars 1.21k forks source link

any_completion_handler is not compatible with BOOST_ASIO_USE_TS_EXECUTOR_AS_DEFAULT #1386

Open anarthal opened 10 months ago

anarthal commented 10 months ago

Minimal reproducible example: https://godbolt.org/z/fE3nGv4vf

This has been reported by a user of Boost.MySQL that is trying to build the library with BOOST_ASIO_USE_TS_EXECUTOR_AS_DEFAULT and failing. Not having this compatibility means that we can't use any_completion_handler in library code.

ashtum commented 10 months ago

It seems that when BOOST_ASIO_USE_TS_EXECUTOR_AS_DEFAULT is defined, Asio utilizes the executor as the any_completion_executor type: https://github.com/chriskohlhoff/asio/blob/fa27820c05afd740fa2adc1ecfb9da5afe026443/asio/include/asio/any_completion_executor.hpp#L31 However, when it attempts to use the noexcept constructor of any_completion_executor : https://github.com/chriskohlhoff/asio/blob/fa27820c05afd740fa2adc1ecfb9da5afe026443/asio/include/asio/any_completion_handler.hpp#L120 since it is an alias of executor type, it lacks such a constructor. If we remove the std::nothrow tag, it works.