C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Make inline implicit for static data members with in-class initialiser

From: Tom Honermann <tom_at_[hidden]>
Date: Thu, 18 Jan 2024 11:53:27 -0500
On 1/18/24 9:08 AM, ஜெய்கணேஷ் குமரன் via Std-Proposals wrote:
> Hello all,
>
> Currently, in C++ you must put the inline keyword on to have a static data member with an in-class initialiser.
inline is only needed if the data member is not declared const.
> I reälly find this unnecessary, as it is obvious that the data member needs to be inline to have an in-class initialiser.
>
> Current:
> inline static type s_member = ...;
>
> Proposed:
> static type s_member = ...;

Implicitly declaring the static data member inline would break existing
code like the following by introducing a redefinition.

    struct S {
       static const int sdm = 1;
    };
    const int S::sdm;

Tom.

>
> Note: I do not have the time to participate in standardisation in order to open formal proposals, but I wish someöne else does based on my ideas.
>
> Thanks,
> Jaiganésh Kumaran.

Received on 2024-01-18 16:53:29