C++ Logo

STD-PROPOSALS

Advanced search

Subject: Re: [std-proposals] Infer member type (`auto`) when using default member initializer
From: Ville Voutilainen (ville.voutilainen_at_[hidden])
Date: 2019-11-14 05:27:41


On Thu, 14 Nov 2019 at 12:58, Dusan Jovanovic via Std-Proposals
<std-proposals_at_[hidden]> wrote:
>
> Hi,
>
>
> We would like to create a proposal for extending the scope of auto keyword and to allow for its usage for declaring class members when using default member initialization.
>
>
> struct Foo {
>
> auto bar = makeBar();
>
> };
>
>
> In our codebase we encountered a need for this macro:
>
>
> #define AUTO_MEMBER(NAME, ...) decltype(__VA_ARGS__) NAME = __VA_ARGS__;
>
>
> To be used as such:
>
>
> struct Foo {
>
> AUTO_MEMBER(bar, makeBar())
>
> };
>
>
> But this has its limitations and a language support for this use case would be nice.
>
> Is there a reason why this was not done so far? Would this be something worth pursuing?

Here: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n3897.html


STD-PROPOSALS list run by herb.sutter at gmail.com

Standard Proposals Archives on Google Groups