Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- template<typename T, typename Y> auto operator+(std::optional<T> lhs, std::optional<Y> rhs) -> std::optional<decltype(*lhs + *rhs)> {
- if (!lhs || !rhs)
- return none;
- return *lhs + *rhs;
- }
- std::optional<T> f() {
- auto x = something();
- auto x2 = something_else();
- return x + x2;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement