`tl::make_unexpected()` should be `[[nodiscard]]`
azais-corentin opened this issue · 0 comments
azais-corentin commented
As the titles says, the function tl::make_unexpected()
should be marked [[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.