From 58753ba33c678befc3404aa8b2e1916b004a591d Mon Sep 17 00:00:00 2001 From: Johan Jansen Date: Thu, 31 Oct 2019 21:38:37 +0100 Subject: [PATCH] Fix some virtual override warnings --- httplib.h | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/httplib.h b/httplib.h index f637847..1540ea1 100644 --- a/httplib.h +++ b/httplib.h @@ -311,7 +311,7 @@ struct Response { class Stream { public: - virtual ~Stream() {} + virtual ~Stream() = default; virtual int read(char *ptr, size_t size) = 0; virtual int write(const char *ptr, size_t size1) = 0; virtual int write(const char *ptr) = 0; @@ -326,7 +326,7 @@ class SocketStream : public Stream { public: SocketStream(socket_t sock, time_t read_timeout_sec, time_t read_timeout_usec); - virtual ~SocketStream(); + ~SocketStream() override; int read(char *ptr, size_t size) override; int write(const char *ptr, size_t size) override; @@ -342,8 +342,8 @@ private: class BufferStream : public Stream { public: - BufferStream() {} - virtual ~BufferStream() {} + BufferStream() = default; + ~BufferStream() override = default; int read(char *ptr, size_t size) override; int write(const char *ptr, size_t size) override; @@ -359,8 +359,8 @@ private: class TaskQueue { public: - TaskQueue() {} - virtual ~TaskQueue() {} + TaskQueue() = default; + virtual ~TaskQueue() = default; virtual void enqueue(std::function fn) = 0; virtual void shutdown() = 0; }; @@ -368,7 +368,7 @@ public: #if CPPHTTPLIB_THREAD_POOL_COUNT > 0 class ThreadPool : public TaskQueue { public: - ThreadPool(size_t n) : shutdown_(false) { + explicit ThreadPool(size_t n) : shutdown_(false) { while (n) { auto t = std::make_shared(worker(*this)); threads_.push_back(t); @@ -377,15 +377,15 @@ public: } ThreadPool(const ThreadPool &) = delete; - virtual ~ThreadPool() {} + ~ThreadPool() override = default; - virtual void enqueue(std::function fn) override { + void enqueue(std::function fn) override { std::unique_lock lock(mutex_); jobs_.push_back(fn); cond_.notify_one(); } - virtual void shutdown() override { + void shutdown() override { // Stop all worker threads... { std::unique_lock lock(mutex_); @@ -402,7 +402,7 @@ public: private: struct worker { - worker(ThreadPool &pool) : pool_(pool) {} + explicit worker(ThreadPool &pool) : pool_(pool) {} void operator()() { for (;;) {