3 ms·
You can use a union + tag(which the same as Rust uses which is why they're called Tagged Unions) however you run into issues with constructors/destructors. You
by vvanders 10y ago
You can use a union + tag(which the same as Rust uses which is why they're called Tagged Unions) however you run into issues with constructors/destructors. You can do something similar with placement new/delete but it requires some hoops.
Honestly most error codes are small enough that you can just pay the hit for it on the stack and discard it once you've handled the good/bad case.