Skip to content

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

@viboes

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions