Skip to content

Commit 6e56b42

Browse files
authored
add explicit missing in constructors (#58)
1 parent 16e8875 commit 6e56b42

18 files changed

Lines changed: 43 additions & 36 deletions

examples/capy_stream_await.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
class StreamIoAwaitable {
88
public:
9-
StreamIoAwaitable(cudaStream_t stream) : m_stream(stream) {}
9+
explicit StreamIoAwaitable(cudaStream_t stream) : m_stream(stream) {}
1010

1111
bool await_ready() const noexcept { return false; }
1212

examples/capy_task.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ template <boost::capy::Executor Ex>
2727
class VerboseExecutor {
2828

2929
public:
30-
VerboseExecutor(Ex& ex) : m_executor(&ex) {
30+
explicit VerboseExecutor(Ex& ex) : m_executor(&ex) {
3131
static_assert(boost::capy::Executor<VerboseExecutor<Ex>>,
3232
"VerboseExecutor should be a valid capy Executor");
3333
}

examples/capy_task_arena_executor.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
class TaskArenaContext : public boost::capy::execution_context {
99
public:
10-
TaskArenaContext(tbb::task_arena& arena) : m_arena(&arena) {}
10+
explicit TaskArenaContext(tbb::task_arena& arena) : m_arena(&arena) {}
1111

1212
void schedule(std::coroutine_handle<> h) const {
1313
m_arena->enqueue([h]() { h.resume(); });
@@ -23,7 +23,7 @@ class TaskArenaContext : public boost::capy::execution_context {
2323
class TaskArenaExecutor {
2424

2525
public:
26-
TaskArenaExecutor(TaskArenaContext& context) noexcept
26+
explicit TaskArenaExecutor(TaskArenaContext& context) noexcept
2727
: m_context(&context) {
2828
static_assert(boost::capy::Executor<TaskArenaExecutor>,
2929
"TaskArenaExecutor should be a valid capy Executor");

examples/exec_stream_await_sender.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ class stream_await_sender {
1717
using completion_signatures =
1818
stdexec::completion_signatures<stdexec::set_value_t(cudaError_t)>;
1919

20-
stream_await_sender(const cudaStream_t stream) : m_stream(stream) {}
20+
explicit stream_await_sender(const cudaStream_t stream)
21+
: m_stream(stream) {}
2122
stdexec::env<> get_env() const noexcept { return {}; }
2223

2324
template <stdexec::receiver Receiver>

include/CoroutineTests/alien/algorithm.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ class [[nodiscard]] Task {
5757
using scheduler_type = std::function<void(std::coroutine_handle<>)>;
5858

5959
// Required by coroutines
60-
Task(handle_type coroutine_handle) : m_coroutine(coroutine_handle) {}
60+
explicit Task(handle_type coroutine_handle)
61+
: m_coroutine(coroutine_handle) {}
6162
~Task() {
6263
if (m_coroutine) {
6364
m_coroutine.destroy();
@@ -100,7 +101,7 @@ struct Task<ResultType>::promise_type {
100101
const auto& get_scheduler() const { return m_scheduler; }
101102

102103
// Required by coroutines: create the object
103-
Task get_return_object() { return {handle_type::from_promise(*this)}; }
104+
Task get_return_object() { return Task{handle_type::from_promise(*this)}; }
104105
// Required by coroutines: suspend immediately on start (lazy execution)
105106
std::suspend_always initial_suspend() const noexcept { return {}; }
106107
// Required by coroutines: suspend on completion

include/CoroutineTests/alien/manual_algorithm.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ class [[nodiscard]] Task {
4949
using scheduler_type = std::function<void(std::coroutine_handle<>)>;
5050

5151
// Required by coroutines
52-
Task(handle_type coroutine_handle) : m_coroutine(coroutine_handle) {}
52+
explicit Task(handle_type coroutine_handle)
53+
: m_coroutine(coroutine_handle) {}
5354
~Task() {
5455
if (m_coroutine) {
5556
m_coroutine.destroy();
@@ -100,7 +101,7 @@ struct Task<ResultType>::promise_type {
100101
const auto& get_scheduler() const { return m_scheduler; }
101102

102103
// Required by coroutines: create the object
103-
Task get_return_object() { return {handle_type::from_promise(*this)}; }
104+
Task get_return_object() { return Task{handle_type::from_promise(*this)}; }
104105
// Required by coroutines: suspend immediately on start (lazy execution)
105106
std::suspend_always initial_suspend() const noexcept { return {}; }
106107
// Required by coroutines: suspend on completion

include/CoroutineTests/alien/schedule_on.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ class [[nodiscard]] Task {
3434
std::coroutine_handle<promise_type>; // not required but useful
3535

3636
// Constructor from coroutine handle
37-
Task(handle_type coroutine_handle) : m_coroutine(coroutine_handle) {}
37+
explicit Task(handle_type coroutine_handle)
38+
: m_coroutine(coroutine_handle) {}
3839
~Task() {
3940
if (m_coroutine) {
4041
m_coroutine.destroy();
@@ -122,7 +123,7 @@ struct Task<ResultType>::promise_type
122123
void reschedule() { m_scheduler(handle_type::from_promise(*this)); }
123124

124125
// Required by coroutines: create the object
125-
Task get_return_object() { return {handle_type::from_promise(*this)}; }
126+
Task get_return_object() { return Task{handle_type::from_promise(*this)}; }
126127
// Required by coroutines: suspend immediately on start (lazy execution)
127128
std::suspend_always initial_suspend() const { return {}; }
128129
// Required by coroutines: handle completion and resume parent

include/CoroutineTests/alien/subtool.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ class [[nodiscard]] Task {
6767
std::coroutine_handle<promise_type>; // not required but useful
6868

6969
// Constructor from coroutine handle
70-
Task(handle_type coroutine_handle) : m_coroutine(coroutine_handle) {}
70+
explicit Task(handle_type coroutine_handle)
71+
: m_coroutine(coroutine_handle) {}
7172
~Task() {
7273
if (m_coroutine) {
7374
m_coroutine.destroy();
@@ -145,7 +146,7 @@ struct Task<ResultType>::promise_type
145146
void reschedule() { m_scheduler(handle_type::from_promise(*this)); }
146147

147148
// Required by coroutines: create the object
148-
Task get_return_object() { return {handle_type::from_promise(*this)}; }
149+
Task get_return_object() { return Task{handle_type::from_promise(*this)}; }
149150
// Required by coroutines: suspend immediately on start (lazy execution)
150151
std::suspend_always initial_suspend() const { return {}; }
151152
// Required by coroutines: handle completion and resume parent

include/CoroutineTests/alien/tool.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ class [[nodiscard]] Task {
6767
std::coroutine_handle<promise_type>; // not required but useful
6868

6969
// Constructor from coroutine handle
70-
Task(handle_type coroutine_handle) : m_coroutine(coroutine_handle) {}
70+
explicit Task(handle_type coroutine_handle)
71+
: m_coroutine(coroutine_handle) {}
7172
~Task() {
7273
if (m_coroutine) {
7374
m_coroutine.destroy();
@@ -145,7 +146,7 @@ struct Task<ResultType>::promise_type
145146
void reschedule() { m_scheduler(handle_type::from_promise(*this)); }
146147

147148
// Required by coroutines: create the object
148-
Task get_return_object() { return {handle_type::from_promise(*this)}; }
149+
Task get_return_object() { return Task{handle_type::from_promise(*this)}; }
149150
// Required by coroutines: suspend immediately on start (lazy execution)
150151
std::suspend_always initial_suspend() const { return {}; }
151152
// Required by coroutines: handle completion and resume parent

include/CoroutineTests/async.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class [[nodiscard]] Async {
1515
using handle_type =
1616
std::coroutine_handle<promise_type>; // not required but useful
1717

18-
Async(handle_type coroutine_handle)
18+
explicit Async(handle_type coroutine_handle)
1919
: m_coroutine(coroutine_handle) {} // required by coroutines
2020
~Async() {
2121
if (m_coroutine) {
@@ -71,7 +71,7 @@ struct Async::promise_type {
7171
}
7272
// required by coroutines
7373
Async get_return_object() {
74-
return {Async::handle_type::from_promise(*this)};
74+
return Async{Async::handle_type::from_promise(*this)};
7575
}
7676
// called on coroutine start
7777
std::suspend_always initial_suspend() const { return {}; }

0 commit comments

Comments
 (0)