Advertisement
Guest User

Untitled

a guest
Aug 27th, 2013
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.31 KB | None | 0 0
  1. template<typename T, typename Y> auto operator+(std::optional<T> lhs, std::optional<Y> rhs) -> std::optional<decltype(*lhs + *rhs)> {
  2. if (!lhs || !rhs)
  3. return none;
  4. return *lhs + *rhs;
  5. }
  6.  
  7. std::optional<T> f() {
  8. auto x = something();
  9. auto x2 = something_else();
  10. return x + x2;
  11. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement