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 12:06:23 -0500
On 1/18/24 11:59 AM, Brian Bi via Std-Proposals wrote:
>
>
> On Thu, Jan 18, 2024 at 11:53 AM Tom Honermann via Std-Proposals
> <std-proposals_at_[hidden]> wrote:
>
> 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;
>
> In C++17, `constexpr` static data members were made implicitly inline
> and the out-of-class definition was changed to be a redundant
> redeclaration. In principle, this could be done for other types of
> static data members too, couldn't it?

I'm not sure. The kind of symbol produced could change and thereby
impact compatibility with previously built code.

Tom.

> 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.
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>
>
>
> --
> /Brian Bi/
>

Received on 2024-01-18 17:06:28