3 ms·
How about wrapping the return value in a templated error class that the caller has to explicitly unwrap with an error handler to be able to use?
by sbmassey 11y ago
How about wrapping the return value in a templated error class that the caller has to explicitly unwrap with an error handler to be able to use?
- azov 11y agoThat will help if there is a value to return - but then it's not much better than just returning something invalid, like a NULL pointer. If the only return value is success/failure you need compiler support (1) to ensure it's not ignored. (1) There are clever hacks to mimic this behavior to some extent, but I don't even want to go there. If you really want this feature - just use a language that has it.