Commit d54b005b authored by Kenton Varda's avatar Kenton Varda

Implement const version of Maybe<T&>::map().

parent bacdc241
......@@ -1222,6 +1222,16 @@ public:
}
}
template <typename Func>
auto map(Func&& f) const -> Maybe<decltype(f(instance<const T&>()))> {
if (ptr == nullptr) {
return nullptr;
} else {
const T& ref = *ptr;
return f(ref);
}
}
private:
T* ptr;
......
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