Commit 579b6fa2 authored by Dominik Charousset's avatar Dominik Charousset

Allow conversion from optional<U> to optional<T>

parent f85c761a
......@@ -48,6 +48,20 @@ public:
cr(std::move(value));
}
template <class U>
optional(const optional<U>& other) : valid_(false) {
if (other.valid()) {
cr(other.get());
}
}
template <class U>
optional(optional<U>&& other) : valid_(false) {
if (other.valid()) {
cr(std::move(other.get()));
}
}
optional(const optional& other) : valid_(false) {
if (other.valid_) {
cr(other.value_);
......@@ -179,6 +193,14 @@ public:
// nop
}
template <class U>
optional(const optional<U>& value) {
if (value)
value_ = &value.get();
else
value_ = nullptr;
}
optional(const optional& other) = default;
optional& operator=(const optional& other) = default;
......
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