Date: Fri, 30 Jun 2023 09:37:01 -0400
On Fri, Jun 30, 2023 at 3:19 AM Frederick Virchanza Gotham via
Std-Proposals <std-proposals_at_[hidden]> wrote:
>
> On Thu, Jun 29, 2023 at 10:37 PM Jason McKesson via Std-Proposals
> <std-proposals_at_[hidden]> wrote:
> >
> > ```
> > some_func(g_obj.synchronize()); //Should only synchronize for the
> > duration of the function call.
> > ```
>
>
> This is why I called it [[nodiscard_scope]]. It means that you don't
> discard the return value, and also that you are careful about its
> scope.
> I think the following two should be permissible:
>
> some_func( g_obj.synchronize());
> some_func(*g_obj.synchronize());
>
> because the scoping of the return value is okay. The following should
> be a warning/error though:
>
> auto &ref = *g_obj.synchronize();
I do not believe there is a coherent set of rules that would make the
first two viable but not the third. You can vaguely gesture towards
"scope" or whatever, but we're talking about a change to the standard.
It has to be precise and specific.
Std-Proposals <std-proposals_at_[hidden]> wrote:
>
> On Thu, Jun 29, 2023 at 10:37 PM Jason McKesson via Std-Proposals
> <std-proposals_at_[hidden]> wrote:
> >
> > ```
> > some_func(g_obj.synchronize()); //Should only synchronize for the
> > duration of the function call.
> > ```
>
>
> This is why I called it [[nodiscard_scope]]. It means that you don't
> discard the return value, and also that you are careful about its
> scope.
> I think the following two should be permissible:
>
> some_func( g_obj.synchronize());
> some_func(*g_obj.synchronize());
>
> because the scoping of the return value is okay. The following should
> be a warning/error though:
>
> auto &ref = *g_obj.synchronize();
I do not believe there is a coherent set of rules that would make the
first two viable but not the third. You can vaguely gesture towards
"scope" or whatever, but we're talking about a change to the standard.
It has to be precise and specific.
Received on 2023-06-30 13:37:11