ptal / expected

What did you expect?
113 stars 18 forks source link

Add a unwrap member function #24

Closed viboes closed 10 years ago

ptal commented 10 years ago

What would be the difference between unwrap and get or operator*?

viboes commented 10 years ago

What get() does? Do you mean value()? unwrap takes in account the state of two nested expected.

Next follows the definition using a non-member function

  template <class T, class E>
  expected<E,T> unwrap(expected<E, expected<E,T> > ee) {
    if (ee) return *ee;
    return ee.get_unexpected();
  }
  template <class T, class E>
  expected<E,T> unwrap(expected<E,T> e) {
    return e;
  }
ptal commented 10 years ago

Ok, I think it makes sense, I'm adding this and redefined mbind in term of fmap.

viboes commented 10 years ago

I suggest to change the title of this issue to Add unwrap member function and make it an enhancement.

viboes commented 10 years ago

https://github.com/ptal/Boost.Expected/commit/56051bbc6e5ffa1a32946c550e85a5f69f900c1a

https://github.com/ptal/Boost.Expected/commit/a2407f89ecdd3b64482471bbc8d9c507980ee0f1