Open azais-corentin opened 1 year ago
As the titles says, the function tl::make_unexpected() should be marked [[nodiscard]].
tl::make_unexpected()
[[nodiscard]]
It would prevent misuse when forgetting to return the unexpected value:
enum class ErrorType{ kNullParameter }; struct ResultType{}; tl::expected<ResultType, ErrorType> myFunction(int nonNullParameter) { if(nonNullParameter== 0) { tl::make_unexpected(ErrorType::kNullParameter); } return ResultType{}; }
Here I forgot to return the unexpected value and there's no warning whatsoever.
As the titles says, the function
tl::make_unexpected()
should be marked[[nodiscard]]
.It would prevent misuse when forgetting to return the unexpected value:
Here I forgot to return the unexpected value and there's no warning whatsoever.