Skip to content

Change StatusCode::orThrow so that the return value can be ignored

As discussed in !988 (comment 3273867), StatusCode::orThrow can only return SUCCESS (or throw an exception), so checking the return value is not very interesting. Yet, it cannot be made return void for backward compatibility.

This change uses the fact that a [[nodiscard]] class triggers the warning only when returned by value (see https://en.cppreference.com/w/cpp/language/attributes/nodiscard), to allow users to ignore the return value of StatusCode::orThrow.

I also changed the signature to accept std::string_view instead of forcing a string copy at the invocation point.

Closes #118 (closed)

Edited by Marco Clemencic

Merge request reports