Skip to content

Mark as [[nodiscard]] #74

@martinmoene

Description

@martinmoene

See microsoft/STL@7643c27 via PR nonstd-lite/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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions