-
Notifications
You must be signed in to change notification settings - Fork 26
Open
Description
Summary
Consider adding [[nodiscard]] annotations to generated C++ code for methods like Ok(), Read(), TryToWrite(), etc. to help catch bugs where return values are accidentally ignored.
Background
This was originally part of PR #235 (optimization for conditional fields), but was requested to be split out for separate discussion since [[nodiscard]] is a C++17 feature and there may need to be a broader discussion about C++14 vs C++17 support.
Considerations
[[nodiscard]]was introduced in C++17- Current Emboss may support C++14 users
- Options to consider:
- Require C++17 minimum and add
[[nodiscard]]unconditionally - Use a macro that expands to
[[nodiscard]]on C++17+ and nothing on C++14 - Keep C++14 compatibility and don't add
[[nodiscard]]
- Require C++17 minimum and add
Affected methods
Key methods that would benefit from [[nodiscard]]:
Ok()- return value indicates validityRead()/UncheckedRead()- return values are the point of the callTryToWrite()/TryToCopyFrom()- return value indicates successIsComplete()- return value indicates completenessCouldWriteValue()- return value indicates writability
cc @EricRahm (requested this be discussed separately)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels