Commit 890a2485 authored by Joseph Noir's avatar Joseph Noir

Add conversion constructor

parent 873538b0
......@@ -93,13 +93,29 @@ public:
cr_error(other.error_);
}
maybe(maybe&& other) : valid_(other.valid_) {
maybe(maybe&& other) {
if (other.valid_)
cr_moved_value(other.value_);
else
cr_error(std::move(other.error_));
}
template <class U>
maybe(maybe<U>&& other) {
if (other)
cr_moved_value(*other);
else
cr_error(std::move(other.error()));
}
template <class U>
maybe(const maybe<U>& other) {
if (other)
cr_value(*other);
else
cr_error(other.error());
}
~maybe() {
destroy();
}
......
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