Skip to content

Do we need a expected<T,E>::has_error function? #18

Description

@viboes

More relevant might be exponential backoff, which would look much uglier if you had to test for whether or not there was a status.

     e = function();
     while ( e.status == timeout ) {
       sleep(delay);
       delay *=2; 
     }

Here we have a value or a hard error. This use case would need to use something like has_error

 e = function();
  while ( has_error(e, timeout) ) {
    sleep(delay);
    delay *=2; 
}

where

template <class E, class T>
bool has_error(expected<E,T> const&, E err) {
  if (e) return false;
  else return error()==err;
}

Do we need to add such a has_error function? as member?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions