-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e10f39a
commit 187a306
Showing
1 changed file
with
26 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# result_code | ||
|
||
## Motivation | ||
It is header only implementation of `std::expected`-like solution. Allows for returning either value or error (in that case no value is contained in the returned object). | ||
|
||
## Functionality | ||
|
||
Define return type as a `Result::ResultValue<T,E>` and return either `Success<T>` or `Failure<E>` using `Ok(T)` or `Error(E)`. There are move ctors defined for non-trivial types to avoid unnecessary allocations. | ||
After object is returned its state can be checked and retrieved. | ||
|
||
## Why another implementation? | ||
To learn. To create small useful implementation. | ||
|
||
## Further work | ||
* [X] Allow to work with codebase where exceptions are not permitted | ||
* [X] Move `T` or `E`, add designated functions | ||
* [X] Allow casting error codes (add operator to make it easier) | ||
* [X] Add possibility to set value/error after object is constructed | ||
* [ ] Change name to be easier to use (instead of `Result::ResultValue` maybe `Result::Expected`) | ||
* [ ] Add tutorial | ||
|
||
## Tutorial | ||
TBD | ||
|
||
## License | ||
Licensed under BSD license. |