On Thu, Jan 18, 2024 at 11:53 AM Tom Honermann via Std-Proposals <std-proposals@lists.isocpp.org> 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?

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@lists.isocpp.org
https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals


--
Brian Bi