diff --git a/examples/capy_stream_await.hpp b/examples/capy_stream_await.hpp index ea9cf30..3edefb6 100644 --- a/examples/capy_stream_await.hpp +++ b/examples/capy_stream_await.hpp @@ -6,7 +6,7 @@ class StreamIoAwaitable { public: - StreamIoAwaitable(cudaStream_t stream) : m_stream(stream) {} + explicit StreamIoAwaitable(cudaStream_t stream) : m_stream(stream) {} bool await_ready() const noexcept { return false; } diff --git a/examples/capy_task.cpp b/examples/capy_task.cpp index 652a365..319a648 100644 --- a/examples/capy_task.cpp +++ b/examples/capy_task.cpp @@ -27,7 +27,7 @@ template class VerboseExecutor { public: - VerboseExecutor(Ex& ex) : m_executor(&ex) { + explicit VerboseExecutor(Ex& ex) : m_executor(&ex) { static_assert(boost::capy::Executor>, "VerboseExecutor should be a valid capy Executor"); } diff --git a/examples/capy_task_arena_executor.hpp b/examples/capy_task_arena_executor.hpp index af0dbfc..ab1d3e6 100644 --- a/examples/capy_task_arena_executor.hpp +++ b/examples/capy_task_arena_executor.hpp @@ -7,7 +7,7 @@ class TaskArenaContext : public boost::capy::execution_context { public: - TaskArenaContext(tbb::task_arena& arena) : m_arena(&arena) {} + explicit TaskArenaContext(tbb::task_arena& arena) : m_arena(&arena) {} void schedule(std::coroutine_handle<> h) const { m_arena->enqueue([h]() { h.resume(); }); @@ -23,7 +23,7 @@ class TaskArenaContext : public boost::capy::execution_context { class TaskArenaExecutor { public: - TaskArenaExecutor(TaskArenaContext& context) noexcept + explicit TaskArenaExecutor(TaskArenaContext& context) noexcept : m_context(&context) { static_assert(boost::capy::Executor, "TaskArenaExecutor should be a valid capy Executor"); diff --git a/examples/exec_stream_await_sender.hpp b/examples/exec_stream_await_sender.hpp index 76136e0..91ecd49 100644 --- a/examples/exec_stream_await_sender.hpp +++ b/examples/exec_stream_await_sender.hpp @@ -17,7 +17,8 @@ class stream_await_sender { using completion_signatures = stdexec::completion_signatures; - stream_await_sender(const cudaStream_t stream) : m_stream(stream) {} + explicit stream_await_sender(const cudaStream_t stream) + : m_stream(stream) {} stdexec::env<> get_env() const noexcept { return {}; } template diff --git a/include/CoroutineTests/alien/algorithm.hpp b/include/CoroutineTests/alien/algorithm.hpp index c74a842..bb301bd 100644 --- a/include/CoroutineTests/alien/algorithm.hpp +++ b/include/CoroutineTests/alien/algorithm.hpp @@ -57,7 +57,8 @@ class [[nodiscard]] Task { using scheduler_type = std::function)>; // Required by coroutines - Task(handle_type coroutine_handle) : m_coroutine(coroutine_handle) {} + explicit Task(handle_type coroutine_handle) + : m_coroutine(coroutine_handle) {} ~Task() { if (m_coroutine) { m_coroutine.destroy(); @@ -100,7 +101,7 @@ struct Task::promise_type { const auto& get_scheduler() const { return m_scheduler; } // Required by coroutines: create the object - Task get_return_object() { return {handle_type::from_promise(*this)}; } + Task get_return_object() { return Task{handle_type::from_promise(*this)}; } // Required by coroutines: suspend immediately on start (lazy execution) std::suspend_always initial_suspend() const noexcept { return {}; } // Required by coroutines: suspend on completion diff --git a/include/CoroutineTests/alien/manual_algorithm.hpp b/include/CoroutineTests/alien/manual_algorithm.hpp index 16b8d22..9d539cd 100644 --- a/include/CoroutineTests/alien/manual_algorithm.hpp +++ b/include/CoroutineTests/alien/manual_algorithm.hpp @@ -49,7 +49,8 @@ class [[nodiscard]] Task { using scheduler_type = std::function)>; // Required by coroutines - Task(handle_type coroutine_handle) : m_coroutine(coroutine_handle) {} + explicit Task(handle_type coroutine_handle) + : m_coroutine(coroutine_handle) {} ~Task() { if (m_coroutine) { m_coroutine.destroy(); @@ -100,7 +101,7 @@ struct Task::promise_type { const auto& get_scheduler() const { return m_scheduler; } // Required by coroutines: create the object - Task get_return_object() { return {handle_type::from_promise(*this)}; } + Task get_return_object() { return Task{handle_type::from_promise(*this)}; } // Required by coroutines: suspend immediately on start (lazy execution) std::suspend_always initial_suspend() const noexcept { return {}; } // Required by coroutines: suspend on completion diff --git a/include/CoroutineTests/alien/schedule_on.hpp b/include/CoroutineTests/alien/schedule_on.hpp index b4f4b41..bac0b28 100644 --- a/include/CoroutineTests/alien/schedule_on.hpp +++ b/include/CoroutineTests/alien/schedule_on.hpp @@ -34,7 +34,8 @@ class [[nodiscard]] Task { std::coroutine_handle; // not required but useful // Constructor from coroutine handle - Task(handle_type coroutine_handle) : m_coroutine(coroutine_handle) {} + explicit Task(handle_type coroutine_handle) + : m_coroutine(coroutine_handle) {} ~Task() { if (m_coroutine) { m_coroutine.destroy(); @@ -122,7 +123,7 @@ struct Task::promise_type void reschedule() { m_scheduler(handle_type::from_promise(*this)); } // Required by coroutines: create the object - Task get_return_object() { return {handle_type::from_promise(*this)}; } + Task get_return_object() { return Task{handle_type::from_promise(*this)}; } // Required by coroutines: suspend immediately on start (lazy execution) std::suspend_always initial_suspend() const { return {}; } // Required by coroutines: handle completion and resume parent diff --git a/include/CoroutineTests/alien/subtool.hpp b/include/CoroutineTests/alien/subtool.hpp index 43a18e8..d229dc9 100644 --- a/include/CoroutineTests/alien/subtool.hpp +++ b/include/CoroutineTests/alien/subtool.hpp @@ -67,7 +67,8 @@ class [[nodiscard]] Task { std::coroutine_handle; // not required but useful // Constructor from coroutine handle - Task(handle_type coroutine_handle) : m_coroutine(coroutine_handle) {} + explicit Task(handle_type coroutine_handle) + : m_coroutine(coroutine_handle) {} ~Task() { if (m_coroutine) { m_coroutine.destroy(); @@ -145,7 +146,7 @@ struct Task::promise_type void reschedule() { m_scheduler(handle_type::from_promise(*this)); } // Required by coroutines: create the object - Task get_return_object() { return {handle_type::from_promise(*this)}; } + Task get_return_object() { return Task{handle_type::from_promise(*this)}; } // Required by coroutines: suspend immediately on start (lazy execution) std::suspend_always initial_suspend() const { return {}; } // Required by coroutines: handle completion and resume parent diff --git a/include/CoroutineTests/alien/tool.hpp b/include/CoroutineTests/alien/tool.hpp index 4e4b033..8b7c29a 100644 --- a/include/CoroutineTests/alien/tool.hpp +++ b/include/CoroutineTests/alien/tool.hpp @@ -67,7 +67,8 @@ class [[nodiscard]] Task { std::coroutine_handle; // not required but useful // Constructor from coroutine handle - Task(handle_type coroutine_handle) : m_coroutine(coroutine_handle) {} + explicit Task(handle_type coroutine_handle) + : m_coroutine(coroutine_handle) {} ~Task() { if (m_coroutine) { m_coroutine.destroy(); @@ -145,7 +146,7 @@ struct Task::promise_type void reschedule() { m_scheduler(handle_type::from_promise(*this)); } // Required by coroutines: create the object - Task get_return_object() { return {handle_type::from_promise(*this)}; } + Task get_return_object() { return Task{handle_type::from_promise(*this)}; } // Required by coroutines: suspend immediately on start (lazy execution) std::suspend_always initial_suspend() const { return {}; } // Required by coroutines: handle completion and resume parent diff --git a/include/CoroutineTests/async.hpp b/include/CoroutineTests/async.hpp index ec6f505..6120397 100644 --- a/include/CoroutineTests/async.hpp +++ b/include/CoroutineTests/async.hpp @@ -15,7 +15,7 @@ class [[nodiscard]] Async { using handle_type = std::coroutine_handle; // not required but useful - Async(handle_type coroutine_handle) + explicit Async(handle_type coroutine_handle) : m_coroutine(coroutine_handle) {} // required by coroutines ~Async() { if (m_coroutine) { @@ -71,7 +71,7 @@ struct Async::promise_type { } // required by coroutines Async get_return_object() { - return {Async::handle_type::from_promise(*this)}; + return Async{Async::handle_type::from_promise(*this)}; } // called on coroutine start std::suspend_always initial_suspend() const { return {}; } diff --git a/include/CoroutineTests/datasink.hpp b/include/CoroutineTests/datasink.hpp index ff19e81..1c60276 100644 --- a/include/CoroutineTests/datasink.hpp +++ b/include/CoroutineTests/datasink.hpp @@ -14,7 +14,7 @@ class [[nodiscard]] DataSink { using handle_type = std::coroutine_handle; // not required but useful - DataSink(handle_type coroutine_handle) + explicit DataSink(handle_type coroutine_handle) : m_coroutine(coroutine_handle) {} // required by coroutines ~DataSink() { if (m_coroutine) { @@ -61,7 +61,7 @@ struct DataSink::promise_type { // required by coroutines DataSink get_return_object() { - return {DataSink::handle_type::from_promise(*this)}; + return DataSink{DataSink::handle_type::from_promise(*this)}; } // called on coroutine start // resume immediately and proceed to first co_await diff --git a/include/CoroutineTests/datasource.hpp b/include/CoroutineTests/datasource.hpp index eaf415a..edf679a 100644 --- a/include/CoroutineTests/datasource.hpp +++ b/include/CoroutineTests/datasource.hpp @@ -17,7 +17,7 @@ class [[nodiscard]] DataSource { using handle_type = std::coroutine_handle; // not required but useful - DataSource(handle_type coroutine_handle) + explicit DataSource(handle_type coroutine_handle) : m_coroutine(coroutine_handle) {} // required by coroutines ~DataSource() { if (m_coroutine) { @@ -68,7 +68,7 @@ struct DataSource::promise_type { // required by coroutines DataSource get_return_object() { - return {DataSource::handle_type::from_promise(*this)}; + return DataSource{DataSource::handle_type::from_promise(*this)}; } // called on coroutine start std::suspend_always initial_suspend() const { return {}; } @@ -85,7 +85,7 @@ struct DataSource::promise_type { // This could be potentially replaced by just co_yield template struct OutputAwaiter { - OutputAwaiter(T value) : m_value(value) {} + explicit OutputAwaiter(T value) : m_value(value) {} T m_value; // don't resume immediately bool await_ready() const { return false; } diff --git a/include/CoroutineTests/generator.hpp b/include/CoroutineTests/generator.hpp index bf774c9..b93c74c 100644 --- a/include/CoroutineTests/generator.hpp +++ b/include/CoroutineTests/generator.hpp @@ -18,7 +18,7 @@ class [[nodiscard]] Generator using handle_type = std::coroutine_handle; // not required but useful - Generator(handle_type coroutine_handle) + explicit Generator(handle_type coroutine_handle) : m_coroutine(coroutine_handle) {} // required by coroutines ~Generator() { if (m_coroutine) { @@ -61,8 +61,8 @@ struct Generator::promise_type { T m_current_value; std::exception_ptr m_exception; // required by coroutines - Generator get_return_object() { - return {Generator::handle_type::from_promise(*this)}; + Generator get_return_object() { + return Generator{Generator::handle_type::from_promise(*this)}; } // called on coroutine start std::suspend_always initial_suspend() const { return {}; } diff --git a/include/CoroutineTests/lazy.hpp b/include/CoroutineTests/lazy.hpp index fb2ba8e..85b1fe8 100644 --- a/include/CoroutineTests/lazy.hpp +++ b/include/CoroutineTests/lazy.hpp @@ -17,7 +17,7 @@ class [[nodiscard]] MaybeLazy { using handle_type = std::coroutine_handle; // not required but useful - MaybeLazy(handle_type coroutine_handle) + explicit MaybeLazy(handle_type coroutine_handle) : m_coroutine(coroutine_handle) {} // required by coroutines ~MaybeLazy() { if (m_coroutine) { @@ -61,8 +61,8 @@ struct MaybeLazy::promise_type { T m_current_value; std::exception_ptr m_exception; // required by coroutines - MaybeLazy get_return_object() { - return {MaybeLazy::handle_type::from_promise(*this)}; + MaybeLazy get_return_object() { + return MaybeLazy{MaybeLazy::handle_type::from_promise(*this)}; } // called on coroutine start auto initial_suspend() const { diff --git a/include/CoroutineTests/nestabletask.hpp b/include/CoroutineTests/nestabletask.hpp index 28db10f..086213e 100644 --- a/include/CoroutineTests/nestabletask.hpp +++ b/include/CoroutineTests/nestabletask.hpp @@ -14,7 +14,7 @@ class [[nodiscard]] NestableTask { using handle_type = std::coroutine_handle; // not required but useful - NestableTask(handle_type coroutine_handle) + explicit NestableTask(handle_type coroutine_handle) : m_coroutine(coroutine_handle) {} // required by coroutines ~NestableTask() { if (m_coroutine) { @@ -62,7 +62,7 @@ struct NestableTask::promise_type { handle_type m_parent; // required by coroutines NestableTask get_return_object() { - return {NestableTask::handle_type::from_promise(*this)}; + return NestableTask{NestableTask::handle_type::from_promise(*this)}; } // called on coroutine start std::suspend_always initial_suspend() const { return {}; } diff --git a/include/CoroutineTests/pingpong.hpp b/include/CoroutineTests/pingpong.hpp index 6c3a108..bc9b2fb 100644 --- a/include/CoroutineTests/pingpong.hpp +++ b/include/CoroutineTests/pingpong.hpp @@ -11,7 +11,7 @@ class [[nodiscard]] Player { using handle_type = std::coroutine_handle; // not required but useful - Player(handle_type coroutine_handle) + explicit Player(handle_type coroutine_handle) : m_coroutine(coroutine_handle) {} // required by coroutines ~Player() { if (m_coroutine) { @@ -54,7 +54,7 @@ struct Player::promise_type { handle_type m_peer; // required by coroutines Player get_return_object() { - return {Player::handle_type::from_promise(*this)}; + return Player{Player::handle_type::from_promise(*this)}; } // called on coroutine start std::suspend_always initial_suspend() const { return {}; } diff --git a/include/CoroutineTests/simplegenerator.hpp b/include/CoroutineTests/simplegenerator.hpp index 9881b54..f029854 100644 --- a/include/CoroutineTests/simplegenerator.hpp +++ b/include/CoroutineTests/simplegenerator.hpp @@ -14,7 +14,7 @@ class [[nodiscard]] SimpleGenerator { using handle_type = std::coroutine_handle; // not required but useful - SimpleGenerator(handle_type coroutine_handle) + explicit SimpleGenerator(handle_type coroutine_handle) : m_coroutine(coroutine_handle) {} // required by coroutines ~SimpleGenerator() { if (m_coroutine) { @@ -64,7 +64,8 @@ struct SimpleGenerator::promise_type { T m_value{}; // required by coroutines SimpleGenerator get_return_object() { - return {SimpleGenerator::handle_type::from_promise(*this)}; + return SimpleGenerator{ + SimpleGenerator::handle_type::from_promise(*this)}; } // called on coroutine start std::suspend_always initial_suspend() const { return {}; } diff --git a/include/CoroutineTests/task.hpp b/include/CoroutineTests/task.hpp index 9f59268..c0b9546 100644 --- a/include/CoroutineTests/task.hpp +++ b/include/CoroutineTests/task.hpp @@ -13,7 +13,7 @@ class [[nodiscard]] Task { using handle_type = std::coroutine_handle; // not required but useful - Task(handle_type coroutine_handle) + explicit Task(handle_type coroutine_handle) : m_coroutine(coroutine_handle) {} // required by coroutines ~Task() { if (m_coroutine) { @@ -50,7 +50,7 @@ struct Task::promise_type { std::exception_ptr m_exception; // required by coroutines Task get_return_object() { - return {Task::handle_type::from_promise(*this)}; + return Task{Task::handle_type::from_promise(*this)}; } // called on coroutine start std::suspend_always initial_suspend() const { return {}; }