File: example.cpp

package info (click to toggle)
tl-expected 1.0.0~dfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 344 kB
  • sloc: cpp: 3,120; python: 45; makefile: 9
file content (16 lines) | stat: -rw-r--r-- 272 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include <tl/expected.hpp>

tl::expected<int, const char*> maybe_do_something(int i) {
  if (i < 5) {
    return 0;
  }
  else {
    return tl::make_unexpected("Uh oh");
  }
}

int main(int argc, char** argv) {
  (void)argv;

  return maybe_do_something(0).value_or(-1);
}