Send Std-Proposals mailing list submissions to
std-proposals@lists.isocpp.org
To subscribe or unsubscribe via the World Wide Web, visit
https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
or, via email, send a message with subject or body 'help' to
std-proposals-request@lists.isocpp.org
You can reach the person managing the list at
std-proposals-owner@lists.isocpp.org
When replying, please edit your Subject line so it is more specific
than "Re: Contents of Std-Proposals digest..."
Today's Topics:
1. Enum class extensions (Dragan Grbic)
----------------------------------------------------------------------
Message: 1
Date: Wed, 23 Feb 2022 11:12:15 +0100
From: Dragan Grbic <dgrbic@gmail.com>
To: std-proposals@lists.isocpp.org
Subject: [std-proposals] Enum class extensions
Message-ID:
<CAE_Xj5o2k=pP4Z+B3G=yBo6_=xhe1knH1Z-_4eR-ViQgecJRVA@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
Proposal:
Add static member accessors (generated by compiler) to the enum
class/struct to enable iteration over enum.
enum class Foo {
a,
b = 3,
c = b,
d
}
for (auto e: Foo::enum::values) {
std::cout << e;
}
X::enum::values should return the static const array of underlying type
filled with values from enum ordered as in enum definition. For example
above, it would be [0, 3, 3, 4].
If X::enum::values isn't used, the compiler does not generate the array.
Also, X::enum::names could be added with similar semantics, except that it
would be of type array<char*, N> (where N is count of enum elements).
For the above example it would be ["a", "b", "c", "d"].
-------------- next part --------------
HTML attachment scrubbed and removed
------------------------------
Subject: Digest Footer
Std-Proposals mailing list
Std-Proposals@lists.isocpp.org
https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
------------------------------
End of Std-Proposals Digest, Vol 35, Issue 22
*********************************************