Skip to content

Commit c1ed10d

Browse files
authored
add overload to resolve ambiguity in alien coroutine return_value (#47)
1 parent 7e7eebd commit c1ed10d

4 files changed

Lines changed: 10 additions & 0 deletions

File tree

include/CoroutineTests/alien/algorithm.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,10 @@ struct Task<ResultType>::promise_type {
115115
void return_value(T&& value) {
116116
m_promise.set_value(std::forward<T>(value));
117117
}
118+
// Overload to resolve ambiguity
119+
void return_value(ResultType value) {
120+
m_promise.set_value(std::move(value));
121+
}
118122
};
119123

120124
template <typename ResultType>

include/CoroutineTests/alien/manual_algorithm.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,8 @@ struct Task<ResultType>::promise_type {
113113
void return_value(T&& value) {
114114
m_value = std::forward<T>(value);
115115
}
116+
// Overload to resolve ambiguity
117+
void return_value(ResultType value) { m_value.emplace(std::move(value)); }
116118
};
117119

118120
template <typename ResultType>

include/CoroutineTests/alien/subtool.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,8 @@ struct ReturnHelper {
117117
void return_value(T&& value) {
118118
m_value.emplace(std::forward<T>(value));
119119
}
120+
// Overload to resolve ambiguity
121+
void return_value(ResultType value) { m_value.emplace(std::move(value)); }
120122
};
121123

122124
// Specialization for void return type

include/CoroutineTests/alien/tool.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,8 @@ struct ReturnHelper {
117117
void return_value(T&& value) {
118118
m_value.emplace(std::forward<T>(value));
119119
}
120+
// Overload to resolve ambiguity
121+
void return_value(ResultType value) { m_value.emplace(std::move(value)); }
120122
};
121123

122124
// Specialization for void return type

0 commit comments

Comments
 (0)