• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1+++
2title = "Experimental"
3weight = 15
4+++
5
6In `<boost/outcome/experimental>`, there ships an Outcome-based simulation of
7the proposed [P1095 *Zero overhead deterministic failure*](https://wg21.link/P1095)
8specific implementation of [P0709 *Zero overhead exceptions: Throwing values*](http://wg21.link/P0709), aka "Herbceptions". This library-only implementation lets you use a close simulacrum
9of potential future C++ lightweight exceptions today in [any C++ 14 compiler
10which Outcome supports]({{< relref "/requirements" >}}).
11
12{{% notice warning %}}
13<b>It is stressed, in the strongest possible terms, that any item inside
14`<boost/outcome/experimental>` is subject to unannounced breaking change based
15on WG21 standards committee feedback</b>. That said, the chances are high
16that most of those breaking changes will be to naming rather than to
17fundamental semantics, so you can upgrade with a bit of find and replace.
18There are quite a few large code bases out there
19already using this experimental support in anger, we know it works well
20at scale and it's a good bit superior to `std::error_code` et al on every
21measure.
22{{% /notice %}}
23
24P1095's support library has a reference implementation at https://ned14.github.io/status-code/.
25You will find terse documentation there, and an API reference.
26This library is wholly incorporated into Outcome in the `<boost/outcome/experimental/status-code>`
27directory, with bindings into Outcome provided in the following headers:
28
29- `<boost/outcome/experimental/status_result.hpp>`
30- `<boost/outcome/experimental/status_outcome.hpp>`
31
32These headers import the entire contents of the `BOOST_OUTCOME_SYSTEM_ERROR2_NAMESPACE`
33namespace into the `BOOST_OUTCOME_V2_NAMESPACE::experimental` namespace. You
34can thus address everything in `BOOST_OUTCOME_SYSTEM_ERROR2_NAMESPACE` via
35`BOOST_OUTCOME_V2_NAMESPACE::experimental`.
36
37As P1095 also proposes C language support for lightweight C++ exceptions,
38experimental Outcome also has a macro-based C interface that enables C
39code to work with the C-compatible subset of `status_result<T, E>`:
40
41- `<boost/outcome/experimental/result.h>`
42
43For non-Windows non-POSIX platforms such as some embedded systems, standalone
44Experimental Outcome can be used with the `BOOST_OUTCOME_SYSTEM_ERROR2_NOT_POSIX` macro
45defined. This does not include POSIX headers, and makes available a high fidelity,
46fully deterministic, alternative to C++ exceptions on such platforms.
47