December 11, 2020
On Friday, 11 December 2020 at 20:01:38 UTC, Jacob Carlborg wrote:
> On 2020-12-09 11:11, Mike Parker wrote:
>> This is the feedback thread for the first round of Community Review of DIP 1038, "@nodiscard".
>
> The DIP doesn't mention anything about constructors. It should mention if this attribute can be applied to constructors. It should also mention if it applies to if the attribute is attached to the type and a constructor is called for that type.

These cases are both covered by the rules given in the DIP.

1) A constructor is a function. Therefore, @nodiscard can be applied to a constructor.
2) For any type T, a call to T's constructor is an expression of type T. Therefore, if T is an aggregate type whose declaration is annotated with @nodiscard, that expression will be considered non-discardable.
December 12, 2020
On Wednesday, 9 December 2020 at 20:10:14 UTC, Denis Feklushkin wrote:
> On Wednesday, 9 December 2020 at 14:30:13 UTC, Andrej Mitrovic wrote:
>> On Wednesday, 9 December 2020 at 10:11:52 UTC, Mike Parker wrote:
>>> This is the feedback thread for the first round of Community Review of DIP 1038, "@nodiscard".
>>
>> From the DIP:
>>
>>> By contrast, @nodiscard can be used with any function because all functions have a return type.
>>
>> Just a small implementation note: I think @nodiscard should not apply to void functions.
>
> Do not forgot about templates with auto-inferred return types. It can be void or not, it depend on template arguments.

I have trouble imagining why you would want to mark such a function as @nodiscard in the first place. If you can come up with a plausible example, please reply in the discussion thread.
1 2
Next ›   Last »