Commit a6585202 authored by Matthias Vallentin's avatar Matthias Vallentin

Add missing overload for maybe<void>

parent dd56fb88
......@@ -421,6 +421,14 @@ public:
// nop
}
template <class E,
class = typename std::enable_if<
std::is_error_condition_enum<E>::value
>::type>
maybe(E error_code_enum) : error_{error_code_enum} {
// nop
}
maybe& operator=(const none_t&) {
error_.clear();
return *this;
......@@ -431,6 +439,15 @@ public:
return *this;
}
template <class E,
class = typename std::enable_if<
std::is_error_condition_enum<E>::value
>::type>
maybe& operator=(E error_code_enum) {
error_ = error_code_enum;
return *this;
}
bool available() const {
return false;
}
......
......@@ -104,4 +104,10 @@ CAF_TEST(maybe_void) {
CAF_CHECK(! m.empty());
CAF_CHECK(m.error());
CAF_CHECK(m.error() == std::errc::invalid_argument);
// Implicit construction.
auto f = []() -> maybe<void> {
return std::errc::invalid_argument;
};
auto val = f();
CAF_CHECK(! val && val.error() == std::errc::invalid_argument);
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment