From a0d2bc9769b882282dcdcfc42c63e1536e21d1ea Mon Sep 17 00:00:00 2001 From: Nekotekina Date: Wed, 26 Feb 2020 21:00:10 +0300 Subject: [PATCH] named_thread: allow default constructor only with thread_name In C++20, lambdas may be default-constructible allowing nasty stuff. --- Utilities/Thread.h | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/Utilities/Thread.h b/Utilities/Thread.h index 3fc2fc3260..67ade70ef1 100644 --- a/Utilities/Thread.h +++ b/Utilities/Thread.h @@ -361,26 +361,14 @@ class named_thread final : public Context, result_storage_t, thread_bas return thread::finalize(0); } - static decltype(auto) get_default_thread_name() - { - if constexpr (thread_thread_name()) - { - return Context::thread_name; - } - else - { - return "Unnamed Thread"; - } - } - friend class thread_ctrl; public: // Default constructor - template , typename = std::enable_if_t> + template && thread_thread_name(), typename = std::enable_if_t> named_thread() : Context() - , thread(get_default_thread_name()) + , thread(Context::thread_name) { thread::start(&named_thread::entry_point); }