• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1+++
2title = "Example C++ function"
3description = ""
4weight = 20
5+++
6
7Let us start with a simple C++ function which we wish to make available to C code:
8
9{{% snippet "cpp_api.cpp" "function" %}}
10
11As the alias `status_result<size_t>` defaults the erased type to the alias `system_code`,
12the `to_string()` function returns (in concrete types) `basic_result<size_t, status_code<erased<intptr_t>>>`.
13
14The standard Outcome function referenced is documented at
15{{% api "std::error_code error_from_exception(std::exception_ptr &&ep = std::current_exception(), std::error_code not_matched = std::make_error_code(std::errc::resource_unavailable_try_again)) noexcept" %}}.
16The proposed `<system_error2>` reference library implementation provides an identically named
17function taking similar parameters, but it returns a `outcome_e::system_code` (`status_code<erased<intptr_t>>`) instead of a `std::error_code`.
18
19