From eab43f3518ab3dbf7f74573085918b139933464f Mon Sep 17 00:00:00 2001 From: Ben Clayton Date: Wed, 4 Dec 2019 12:55:32 +0000 Subject: [PATCH] net::Server: Fix onError parameter default. The onError parameter of Server::start was default initialized with OnError(), which is an 'invalid target', not a no-op implementation. Replace with a true no-op implementation. --- include/dap/network.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/include/dap/network.h b/include/dap/network.h index df00cb8..d0d76e8 100644 --- a/include/dap/network.h +++ b/include/dap/network.h @@ -28,6 +28,9 @@ std::shared_ptr connect(const char* addr, int port); // Server implements a basic TCP server. class Server { + // IgnoreErrors matches the OnError signature, and does nothing. + static inline void IgnoreErrors(const char*) {} + public: using OnError = std::function; using OnConnect = std::function&)>; @@ -42,7 +45,7 @@ class Server { // onError will be called for any connection errors. virtual bool start(int port, const OnConnect& callback, - const OnError& onError = OnError()) = 0; + const OnError& onError = IgnoreErrors) = 0; // stop() stops listening for connections. // stop() is implicitly called on destruction.