2019-03-01 03:51:12 -06:00
|
|
|
#include <tl/expected.hpp>
|
|
|
|
|
|
|
|
|
|
tl::expected<int, const char*> maybe_do_something(int i) {
|
|
|
|
|
if (i < 5) {
|
|
|
|
|
return 0;
|
2019-04-26 13:44:27 +01:00
|
|
|
}
|
|
|
|
|
else {
|
2019-03-01 03:51:12 -06:00
|
|
|
return tl::make_unexpected("Uh oh");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int main(int argc, char** argv) {
|
|
|
|
|
(void)argv;
|
|
|
|
|
|
|
|
|
|
return maybe_do_something(0).value_or(-1);
|
2019-04-26 13:44:27 +01:00
|
|
|
}
|