[nostalgia] Remove nodiscard from handbook, as ox::Error is always nodiscard now

This commit is contained in:
Gary Talent 2020-10-12 20:03:05 -05:00
parent af71bef4f7
commit 0bbea9c6d5

View File

@ -144,10 +144,6 @@ extra fields to enhance debugability. If instantiated through the ```OxError(x)`
macro, it will also include the file and line of the error. The ```OxError(x)``` macro, it will also include the file and line of the error. The ```OxError(x)```
macro should only be used for the initial instantiation of an ```ox::Error```. macro should only be used for the initial instantiation of an ```ox::Error```.
While not strictly necessary, it is a very helpful thing to mark functions
returning ```ox::Error```s as ```[[nodiscard]]```. This will make sure no
errors are accidentally ignored.
In addition to ```ox::Error``` there is also the template ```ox::ValErr<T>```. In addition to ```ox::Error``` there is also the template ```ox::ValErr<T>```.
```ox::ValErr``` simply wraps the type T value in a struct that also includes ```ox::ValErr``` simply wraps the type T value in a struct that also includes
error information, which allows the returning of a value and an error without error information, which allows the returning of a value and an error without
@ -156,7 +152,7 @@ resorting to output parameters.
```ox::ValErr``` can be used as follows: ```ox::ValErr``` can be used as follows:
```cpp ```cpp
[[nodiscard]] ox::ValErr<int> foo(int i) { ox::ValErr<int> foo(int i) {
if (i < 10) { if (i < 10) {
return i + 1; // implicitly calls ox::ValErr<T>::ValErr(T) return i + 1; // implicitly calls ox::ValErr<T>::ValErr(T)
} }
@ -199,7 +195,7 @@ void studioCode() {
doStuff(val); doStuff(val);
} }
[[nodiscard]] ox::Error engineCode() { ox::Error engineCode() {
auto [val, err] = foo(1); auto [val, err] = foo(1);
oxReturnError(err); oxReturnError(err);
doStuff(val); doStuff(val);
@ -216,7 +212,7 @@ void studioCode() {
doStuff(valerr.value); doStuff(valerr.value);
} }
[[nodiscard]] ox::Error engineCode() { ox::Error engineCode() {
auto valerr = foo(1); auto valerr = foo(1);
oxReturnError(valerr); oxReturnError(valerr);
doStuff(valerr.value); doStuff(valerr.value);