From 741a2f0638761d3058f8094f591fdc3c56c9ebf3 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Tue, 16 Mar 2021 00:57:33 +0000 Subject: Add requires on factory like functions --- lib/collection.hpp | 2 +- lib/worker.h | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) (limited to 'lib') diff --git a/lib/collection.hpp b/lib/collection.hpp index 1630fcc..cf51157 100644 --- a/lib/collection.hpp +++ b/lib/collection.hpp @@ -15,7 +15,7 @@ public: template auto - create(Params &&... params) + create(Params &&... params) requires std::is_base_of_v { if constexpr (shared) { auto obj = std::make_shared(std::forward(params)...); diff --git a/lib/worker.h b/lib/worker.h index 04e351b..7df16cd 100644 --- a/lib/worker.h +++ b/lib/worker.h @@ -2,6 +2,7 @@ #define WORKER_H #include +class Work; #if __cpp_lib_semaphore # include @@ -12,8 +13,6 @@ # include # include -class Work; - class Worker { public: Worker(); @@ -26,7 +25,7 @@ public: template void - addWork(Params &&... params) + addWork(Params &&... params) requires std::is_base_of_v { addWork(std::make_unique(std::forward(params)...)); } @@ -51,7 +50,7 @@ class Worker { public: template void - addWork(Params &&... params) + addWork(Params &&... params) requires std::is_base_of_v { T(std::forward(params)...).doWork(); } -- cgit v1.2.3