C++ Logo

std-proposals

Advanced search

Re: [std-proposals] A proposal on default enum initialization

From: Oleksandr Koval <oleksandr.koval.dev_at_[hidden]>
Date: Fri, 24 Mar 2023 17:22:14 +0200
>
> No existing code uses "default:" for marking the default enum value
> because currently this syntax is invalid. So this is not a breaking change.

Before this proposal:
ExternalLibrary::Enum e{}; // e == 0

After this proposal (and ExternalLibrary update):
ExternalLibrary::Enum e{}; // e == some default value


On Fri, Mar 24, 2023 at 5:17 PM Andrey Semashev via Std-Proposals <
std-proposals_at_[hidden]> wrote:

> On 3/24/23 18:05, Oleksandr Koval via Std-Proposals wrote:
> > Actually, allowing default values can break
> > existing code because right now `Enum e{};` always means e = 0, after
> > your change the value will be different.
>
> No existing code uses "default:" for marking the default enum value
> because currently this syntax is invalid. So this is not a breaking change.
>
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>


-- 
Regards,
Oleksandr Koval.

Received on 2023-03-24 15:22:26