Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mark as [[nodiscard]] #74

Open
4 tasks
martinmoene opened this issue Dec 17, 2024 · 0 comments
Open
4 tasks

Mark as [[nodiscard]] #74

martinmoene opened this issue Dec 17, 2024 · 0 comments

Comments

@martinmoene
Copy link
Owner

martinmoene commented Dec 17, 2024

See microsoft/STL@7643c27 via PR martinmoene/expected-lite#74.

Plan:


Readme, section Synopsis, Configuration:

#### Disable \[\[nodiscard\]\]

-D<b>xxx\_CONFIG\_NO\_NODISCARD</b>=0
Define this to 1 if you want to compile without \[\[nodiscard\]\]. Note that the default of marking `class xxx` with \[\[nodiscard\]\] is not part of the C++23 standard. The rationale to use \[\[nodiscard\]\] is that unnoticed discarded expected error values may break the error handling flow.

Code:

// Control marking class XXX with [[nodiscard]]]:

#if !defined(xxx_CONFIG_NO_NODISCARD)
# define xxx_CONFIG_NO_NODISCARD  0
#else
# define xxx_CONFIG_NO_NODISCARD  1
#endif
// Presence of C++17 language features:

...
#define xxx_HAVE_NODISCARD   xxx_CPP17_000
// C++ feature usage:

...

#if xxx_HAVE_NODISCARD && !xxx_CONFIG_NO_NODISCARD
# define xxx_NODISCARD  [[nodiscard]]
#else
# define xxx_NODISCARD  /*[[nodiscard]]*/
#endif
template<...>
class xxx_NODISCARD XXX
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant