That is not fully true.
Create a class type with private constructor.
Create the constants as static member variables inside the class.
You can keep a copy constructor public.
-----Ursprüngliche Nachricht-----
Von: Ryan Klaus via Std-Proposals <std-proposals@lists.isocpp.org>
Gesendet: Fr 14.03.2025 21:32
Betreff: Re: [std-proposals] enum with non-integral types
An: std-proposals@lists.isocpp.org;
CC: Ryan Klaus <rfklaus117@gmail.com>;
Why use enumerations over named constants ever? Because new (valid) enumeration values can't be added after the definition.With named constants, a user can just create a new constant of the same type anywhere they like and pass it to any function accepting that type. Nothing explicitly prevents this or tells the user they shouldn't do this outside of documentation.With an enumeration, the writer of the enum gets to define the exact list of constants that can be passed to a function accepting that enum type, barring explicit casts of course. There's no way for a user to expand the list of valid constants without doing something hacky like going to the header and modifying the enumeration directly.On Fri, Mar 14, 2025, 2:37 PM Tiago Freire via Std-Proposals <std-proposals@lists.isocpp.org> wrote:--What would be the benefit of this over let’s say... regular named constants?
Std-Proposals mailing list
Std-Proposals@lists.isocpp.org
https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
-- Std-Proposals mailing list Std-Proposals@lists.isocpp.org https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals