Distinguish constructor overloads by number of arguments.

Single argument constructors with SFINAE constraints were causing
unnecessary template instantiations during overload resolution.
Adding dummy arguments prevents this from happening.
This commit is contained in:
Christopher Kohlhoff 2020-11-11 23:06:33 +11:00
parent 13281c560b
commit d2e5d9a5e4
12 changed files with 68 additions and 69 deletions

View File

@ -159,7 +159,7 @@ public:
* dispatch handlers for any asynchronous operations performed on the timer.
*/
explicit basic_deadline_timer(const executor_type& ex)
: impl_(ex)
: impl_(0, ex)
{
}
@ -178,7 +178,7 @@ public:
typename enable_if<
is_convertible<ExecutionContext&, execution_context&>::value
>::type* = 0)
: impl_(context)
: impl_(0, 0, context)
{
}
@ -193,7 +193,7 @@ public:
* as an absolute time.
*/
basic_deadline_timer(const executor_type& ex, const time_type& expiry_time)
: impl_(ex)
: impl_(0, ex)
{
asio::error_code ec;
impl_.get_service().expires_at(impl_.get_implementation(), expiry_time, ec);
@ -216,7 +216,7 @@ public:
typename enable_if<
is_convertible<ExecutionContext&, execution_context&>::value
>::type* = 0)
: impl_(context)
: impl_(0, 0, context)
{
asio::error_code ec;
impl_.get_service().expires_at(impl_.get_implementation(), expiry_time, ec);
@ -235,7 +235,7 @@ public:
*/
basic_deadline_timer(const executor_type& ex,
const duration_type& expiry_time)
: impl_(ex)
: impl_(0, ex)
{
asio::error_code ec;
impl_.get_service().expires_from_now(
@ -260,7 +260,7 @@ public:
typename enable_if<
is_convertible<ExecutionContext&, execution_context&>::value
>::type* = 0)
: impl_(context)
: impl_(0, 0, context)
{
asio::error_code ec;
impl_.get_service().expires_from_now(

View File

@ -94,7 +94,7 @@ public:
* serial port.
*/
explicit basic_serial_port(const executor_type& ex)
: impl_(ex)
: impl_(0, ex)
{
}
@ -112,7 +112,7 @@ public:
is_convertible<ExecutionContext&, execution_context&>::value,
basic_serial_port
>::type* = 0)
: impl_(context)
: impl_(0, 0, context)
{
}
@ -129,7 +129,7 @@ public:
* port.
*/
basic_serial_port(const executor_type& ex, const char* device)
: impl_(ex)
: impl_(0, ex)
{
asio::error_code ec;
impl_.get_service().open(impl_.get_implementation(), device, ec);
@ -153,7 +153,7 @@ public:
typename enable_if<
is_convertible<ExecutionContext&, execution_context&>::value
>::type* = 0)
: impl_(context)
: impl_(0, 0, context)
{
asio::error_code ec;
impl_.get_service().open(impl_.get_implementation(), device, ec);
@ -173,7 +173,7 @@ public:
* port.
*/
basic_serial_port(const executor_type& ex, const std::string& device)
: impl_(ex)
: impl_(0, ex)
{
asio::error_code ec;
impl_.get_service().open(impl_.get_implementation(), device, ec);
@ -197,7 +197,7 @@ public:
typename enable_if<
is_convertible<ExecutionContext&, execution_context&>::value
>::type* = 0)
: impl_(context)
: impl_(0, 0, context)
{
asio::error_code ec;
impl_.get_service().open(impl_.get_implementation(), device, ec);
@ -219,7 +219,7 @@ public:
*/
basic_serial_port(const executor_type& ex,
const native_handle_type& native_serial_port)
: impl_(ex)
: impl_(0, ex)
{
asio::error_code ec;
impl_.get_service().assign(impl_.get_implementation(),
@ -246,7 +246,7 @@ public:
typename enable_if<
is_convertible<ExecutionContext&, execution_context&>::value
>::type* = 0)
: impl_(context)
: impl_(0, 0, context)
{
asio::error_code ec;
impl_.get_service().assign(impl_.get_implementation(),

View File

@ -116,7 +116,7 @@ public:
* signal set.
*/
explicit basic_signal_set(const executor_type& ex)
: impl_(ex)
: impl_(0, ex)
{
}
@ -133,7 +133,7 @@ public:
typename enable_if<
is_convertible<ExecutionContext&, execution_context&>::value
>::type* = 0)
: impl_(context)
: impl_(0, 0, context)
{
}
@ -152,7 +152,7 @@ public:
* signals.add(signal_number_1); @endcode
*/
basic_signal_set(const executor_type& ex, int signal_number_1)
: impl_(ex)
: impl_(0, ex)
{
asio::error_code ec;
impl_.get_service().add(impl_.get_implementation(), signal_number_1, ec);
@ -178,7 +178,7 @@ public:
typename enable_if<
is_convertible<ExecutionContext&, execution_context&>::value
>::type* = 0)
: impl_(context)
: impl_(0, 0, context)
{
asio::error_code ec;
impl_.get_service().add(impl_.get_implementation(), signal_number_1, ec);
@ -204,7 +204,7 @@ public:
*/
basic_signal_set(const executor_type& ex, int signal_number_1,
int signal_number_2)
: impl_(ex)
: impl_(0, ex)
{
asio::error_code ec;
impl_.get_service().add(impl_.get_implementation(), signal_number_1, ec);
@ -236,7 +236,7 @@ public:
typename enable_if<
is_convertible<ExecutionContext&, execution_context&>::value
>::type* = 0)
: impl_(context)
: impl_(0, 0, context)
{
asio::error_code ec;
impl_.get_service().add(impl_.get_implementation(), signal_number_1, ec);
@ -267,7 +267,7 @@ public:
*/
basic_signal_set(const executor_type& ex, int signal_number_1,
int signal_number_2, int signal_number_3)
: impl_(ex)
: impl_(0, ex)
{
asio::error_code ec;
impl_.get_service().add(impl_.get_implementation(), signal_number_1, ec);
@ -304,7 +304,7 @@ public:
typename enable_if<
is_convertible<ExecutionContext&, execution_context&>::value
>::type* = 0)
: impl_(context)
: impl_(0, 0, context)
{
asio::error_code ec;
impl_.get_service().add(impl_.get_implementation(), signal_number_1, ec);

View File

@ -111,7 +111,7 @@ public:
* dispatch handlers for any asynchronous operations performed on the socket.
*/
explicit basic_socket(const executor_type& ex)
: impl_(ex)
: impl_(0, ex)
{
}
@ -128,7 +128,7 @@ public:
typename enable_if<
is_convertible<ExecutionContext&, execution_context&>::value
>::type* = 0)
: impl_(context)
: impl_(0, 0, context)
{
}
@ -144,7 +144,7 @@ public:
* @throws asio::system_error Thrown on failure.
*/
basic_socket(const executor_type& ex, const protocol_type& protocol)
: impl_(ex)
: impl_(0, ex)
{
asio::error_code ec;
impl_.get_service().open(impl_.get_implementation(), protocol, ec);
@ -168,7 +168,7 @@ public:
typename enable_if<
is_convertible<ExecutionContext&, execution_context&>::value
>::type* = 0)
: impl_(context)
: impl_(0, 0, context)
{
asio::error_code ec;
impl_.get_service().open(impl_.get_implementation(), protocol, ec);
@ -191,7 +191,7 @@ public:
* @throws asio::system_error Thrown on failure.
*/
basic_socket(const executor_type& ex, const endpoint_type& endpoint)
: impl_(ex)
: impl_(0, ex)
{
asio::error_code ec;
const protocol_type protocol = endpoint.protocol();
@ -222,7 +222,7 @@ public:
typename enable_if<
is_convertible<ExecutionContext&, execution_context&>::value
>::type* = 0)
: impl_(context)
: impl_(0, 0, context)
{
asio::error_code ec;
const protocol_type protocol = endpoint.protocol();
@ -247,7 +247,7 @@ public:
*/
basic_socket(const executor_type& ex, const protocol_type& protocol,
const native_handle_type& native_socket)
: impl_(ex)
: impl_(0, ex)
{
asio::error_code ec;
impl_.get_service().assign(impl_.get_implementation(),
@ -275,7 +275,7 @@ public:
typename enable_if<
is_convertible<ExecutionContext&, execution_context&>::value
>::type* = 0)
: impl_(context)
: impl_(0, 0, context)
{
asio::error_code ec;
impl_.get_service().assign(impl_.get_implementation(),

View File

@ -119,7 +119,7 @@ public:
* acceptor.
*/
explicit basic_socket_acceptor(const executor_type& ex)
: impl_(ex)
: impl_(0, ex)
{
}
@ -138,7 +138,7 @@ public:
typename enable_if<
is_convertible<ExecutionContext&, execution_context&>::value
>::type* = 0)
: impl_(context)
: impl_(0, 0, context)
{
}
@ -155,7 +155,7 @@ public:
* @throws asio::system_error Thrown on failure.
*/
basic_socket_acceptor(const executor_type& ex, const protocol_type& protocol)
: impl_(ex)
: impl_(0, ex)
{
asio::error_code ec;
impl_.get_service().open(impl_.get_implementation(), protocol, ec);
@ -180,7 +180,7 @@ public:
typename enable_if<
is_convertible<ExecutionContext&, execution_context&>::value
>::type* = 0)
: impl_(context)
: impl_(0, 0, context)
{
asio::error_code ec;
impl_.get_service().open(impl_.get_implementation(), protocol, ec);
@ -216,7 +216,7 @@ public:
*/
basic_socket_acceptor(const executor_type& ex,
const endpoint_type& endpoint, bool reuse_addr = true)
: impl_(ex)
: impl_(0, ex)
{
asio::error_code ec;
const protocol_type protocol = endpoint.protocol();
@ -268,7 +268,7 @@ public:
typename enable_if<
is_convertible<ExecutionContext&, execution_context&>::value
>::type* = 0)
: impl_(context)
: impl_(0, 0, context)
{
asio::error_code ec;
const protocol_type protocol = endpoint.protocol();
@ -304,7 +304,7 @@ public:
*/
basic_socket_acceptor(const executor_type& ex,
const protocol_type& protocol, const native_handle_type& native_acceptor)
: impl_(ex)
: impl_(0, ex)
{
asio::error_code ec;
impl_.get_service().assign(impl_.get_implementation(),
@ -333,7 +333,7 @@ public:
typename enable_if<
is_convertible<ExecutionContext&, execution_context&>::value
>::type* = 0)
: impl_(context)
: impl_(0, 0, context)
{
asio::error_code ec;
impl_.get_service().assign(impl_.get_implementation(),

View File

@ -175,7 +175,7 @@ public:
* dispatch handlers for any asynchronous operations performed on the timer.
*/
explicit basic_waitable_timer(const executor_type& ex)
: impl_(ex)
: impl_(0, ex)
{
}
@ -194,7 +194,7 @@ public:
typename enable_if<
is_convertible<ExecutionContext&, execution_context&>::value
>::type* = 0)
: impl_(context)
: impl_(0, 0, context)
{
}
@ -209,7 +209,7 @@ public:
* as an absolute time.
*/
basic_waitable_timer(const executor_type& ex, const time_point& expiry_time)
: impl_(ex)
: impl_(0, ex)
{
asio::error_code ec;
impl_.get_service().expires_at(impl_.get_implementation(), expiry_time, ec);
@ -233,7 +233,7 @@ public:
typename enable_if<
is_convertible<ExecutionContext&, execution_context&>::value
>::type* = 0)
: impl_(context)
: impl_(0, 0, context)
{
asio::error_code ec;
impl_.get_service().expires_at(impl_.get_implementation(), expiry_time, ec);
@ -251,7 +251,7 @@ public:
* now.
*/
basic_waitable_timer(const executor_type& ex, const duration& expiry_time)
: impl_(ex)
: impl_(0, ex)
{
asio::error_code ec;
impl_.get_service().expires_after(
@ -276,7 +276,7 @@ public:
typename enable_if<
is_convertible<ExecutionContext&, execution_context&>::value
>::type* = 0)
: impl_(context)
: impl_(0, 0, context)
{
asio::error_code ec;
impl_.get_service().expires_after(

View File

@ -56,7 +56,7 @@ template <typename Executor, typename CandidateExecutor = void,
class handler_work_base
{
public:
explicit handler_work_base(const Executor& ex) ASIO_NOEXCEPT
explicit handler_work_base(int, int, const Executor& ex) ASIO_NOEXCEPT
: executor_(asio::prefer(ex, execution::outstanding_work.tracked))
{
}
@ -116,7 +116,7 @@ class handler_work_base<Executor, CandidateExecutor,
>::type>
{
public:
explicit handler_work_base(const Executor& ex) ASIO_NOEXCEPT
explicit handler_work_base(int, int, const Executor& ex) ASIO_NOEXCEPT
: executor_(ex),
owns_work_(true)
{
@ -191,7 +191,7 @@ class handler_work_base<Executor, void, IoContext, PolymorphicExecutor,
>::type>
{
public:
explicit handler_work_base(const Executor&)
explicit handler_work_base(int, int, const Executor&)
{
}
@ -214,7 +214,7 @@ template <typename Executor, typename IoContext>
class handler_work_base<Executor, void, IoContext, Executor>
{
public:
explicit handler_work_base(const Executor& ex) ASIO_NOEXCEPT
explicit handler_work_base(int, int, const Executor& ex) ASIO_NOEXCEPT
#if !defined(ASIO_NO_TYPEID)
: executor_(
ex.target_type() == typeid(typename IoContext::executor_type)
@ -304,7 +304,8 @@ public:
#endif // defined(ASIO_HAS_VARIADIC_TEMPLATES)
executor_type;
explicit handler_work_base(const executor_type& ex) ASIO_NOEXCEPT
explicit handler_work_base(int, int,
const executor_type& ex) ASIO_NOEXCEPT
#if !defined(ASIO_NO_TYPEID)
: executor_(
ex.target_type() == typeid(typename IoContext::executor_type)
@ -372,7 +373,7 @@ public:
Handler, IoExecutor>::type, IoExecutor> base2_type;
handler_work(Handler& handler, const IoExecutor& io_ex) ASIO_NOEXCEPT
: base1_type(io_ex),
: base1_type(0, 0, io_ex),
base2_type(asio::get_associated_executor(handler, io_ex), io_ex)
{
}
@ -409,7 +410,7 @@ public:
typedef handler_work_base<IoExecutor> base1_type;
handler_work(Handler&, const IoExecutor& io_ex) ASIO_NOEXCEPT
: base1_type(io_ex)
: base1_type(0, 0, io_ex)
{
}

View File

@ -43,7 +43,7 @@ public:
typedef Executor executor_type;
// Construct an I/O object using an executor.
explicit io_object_impl(const executor_type& ex)
explicit io_object_impl(int, const executor_type& ex)
: service_(&asio::use_service<IoObjectService>(
io_object_impl::get_context(ex))),
executor_(ex)
@ -53,9 +53,7 @@ public:
// Construct an I/O object using an execution context.
template <typename ExecutionContext>
explicit io_object_impl(ExecutionContext& context,
typename enable_if<is_convertible<
ExecutionContext&, execution_context&>::value>::type* = 0)
explicit io_object_impl(int, int, ExecutionContext& context)
: service_(&asio::use_service<IoObjectService>(context)),
executor_(context.get_executor())
{

View File

@ -105,7 +105,7 @@ public:
* resolver.
*/
explicit basic_resolver(const executor_type& ex)
: impl_(ex)
: impl_(0, ex)
{
}
@ -122,7 +122,7 @@ public:
typename enable_if<
is_convertible<ExecutionContext&, execution_context&>::value
>::type* = 0)
: impl_(context)
: impl_(0, 0, context)
{
}

View File

@ -85,7 +85,7 @@ public:
* descriptor.
*/
explicit basic_descriptor(const executor_type& ex)
: impl_(ex)
: impl_(0, ex)
{
}
@ -102,7 +102,7 @@ public:
typename enable_if<
is_convertible<ExecutionContext&, execution_context&>::value
>::type* = 0)
: impl_(context)
: impl_(0, 0, context)
{
}
@ -121,7 +121,7 @@ public:
*/
basic_descriptor(const executor_type& ex,
const native_handle_type& native_descriptor)
: impl_(ex)
: impl_(0, ex)
{
asio::error_code ec;
impl_.get_service().assign(impl_.get_implementation(),
@ -148,7 +148,7 @@ public:
typename enable_if<
is_convertible<ExecutionContext&, execution_context&>::value
>::type* = 0)
: impl_(context)
: impl_(0, 0, context)
{
asio::error_code ec;
impl_.get_service().assign(impl_.get_implementation(),

View File

@ -82,7 +82,7 @@ public:
* object handle.
*/
explicit basic_object_handle(const executor_type& ex)
: impl_(ex)
: impl_(0, ex)
{
}
@ -100,7 +100,7 @@ public:
is_convertible<ExecutionContext&, execution_context&>::value,
basic_object_handle
>::type* = 0)
: impl_(context)
: impl_(0, 0, context)
{
}
@ -119,7 +119,7 @@ public:
*/
basic_object_handle(const executor_type& ex,
const native_handle_type& native_handle)
: impl_(ex)
: impl_(0, ex)
{
asio::error_code ec;
impl_.get_service().assign(impl_.get_implementation(), native_handle, ec);
@ -145,7 +145,7 @@ public:
typename enable_if<
is_convertible<ExecutionContext&, execution_context&>::value
>::type* = 0)
: impl_(context)
: impl_(0, 0, context)
{
asio::error_code ec;
impl_.get_service().assign(impl_.get_implementation(), native_handle, ec);

View File

@ -85,7 +85,7 @@ public:
* overlapped handle.
*/
explicit basic_overlapped_handle(const executor_type& ex)
: impl_(ex)
: impl_(0, ex)
{
}
@ -103,7 +103,7 @@ public:
is_convertible<ExecutionContext&, execution_context&>::value,
basic_overlapped_handle
>::type* = 0)
: impl_(context)
: impl_(0, 0, context)
{
}
@ -122,7 +122,7 @@ public:
*/
basic_overlapped_handle(const executor_type& ex,
const native_handle_type& native_handle)
: impl_(ex)
: impl_(0, ex)
{
asio::error_code ec;
impl_.get_service().assign(impl_.get_implementation(), native_handle, ec);
@ -148,7 +148,7 @@ public:
typename enable_if<
is_convertible<ExecutionContext&, execution_context&>::value
>::type* = 0)
: impl_(context)
: impl_(0, 0, context)
{
asio::error_code ec;
impl_.get_service().assign(impl_.get_implementation(), native_handle, ec);