C++ Logo


Advanced search

Subject: [std-proposals] nodiscard
From: Magnus Fromreide (magfr_at_[hidden])
Date: 2020-10-14 03:12:03


I have some ideas about the nodiscard attribute and would like to know if
they are reasonable.

First, I could see a use for binding of the nodiscard attribute to a typedef-
name like this:

typedef [[nodiscard]] int status;


using status = [[nodiscard]] int;

This would make any use of the type status have the nodiscard attribute just
like struct [[nodiscard]] ClassName does for a class.

The use for this feature is in old code following the old C conventions of
returning ints, but still allowing the reaaping of the benefits of
class-level nodiscard.

Second, would it be useful to have a conditional nodiscard like

template <class Result, class Error>
struct [[nodiscard(nodiscard(Result) || nodiscard(Error))]] expected
{ ... };


STD-PROPOSALS list run by std-proposals-owner@lists.isocpp.org

Standard Proposals Archives on Google Groups