[committed] libstdc++: Add std::is_scoped_enum for C++23

Jonathan Wakely jwakely@redhat.com
Thu Apr 8 11:09:20 GMT 2021


On 20/03/21 09:18 -0500, Tim Song wrote:
>On Sat, Mar 20, 2021 at 3:58 AM Jonathan Wakely <jwakely.gcc@gmail.com> wrote:
>>
>>
>>
>> On Sat, 20 Mar 2021, 01:13 Tim Song via Libstdc++, <libstdc++@gcc.gnu.org> wrote:
>>>
>>> On Fri, Mar 19, 2021 at 3:13 PM Jonathan Wakely via Libstdc++
>>> <libstdc++@gcc.gnu.org> wrote:
>>> >
>>> > Implement this C++23 feature, as proposed by P1048R1.
>>> >
>>> > This implementation assumes that a C++23 compiler supports concepts
>>> > already. I don't see any point in using preprocessor hacks to detect
>>> > compilers which define __cplusplus to a post-C++20 value but don't
>>> > support concepts yet.
>>> >
>>> > libstdc++-v3/ChangeLog:
>>> >
>>> >         * include/std/type_traits (is_scoped_enum): Define.
>>> >         * include/std/version (__cpp_lib_is_scoped_enum): Define.
>>> >         * testsuite/20_util/is_scoped_enum/value.cc: New test.
>>> >         * testsuite/20_util/is_scoped_enum/version.cc: New test.
>>> >
>>> > Tested powerpc64le-linux. Committed to trunk.
>>> >
>>>
>>> Using __underlying_type breaks for incomplete enumeration types. GCC
>>> doesn't have incomplete scoped enums due to
>>> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89025 but unscoped ones
>>> exist:
>>>
>>> enum E {
>>>     x = std::is_scoped_enum_v<E>
>>> };
>>
>>
>> Thanks, I'll just use int then. Maybe not until Monday though.
>>
>>
>
>Using int avoids the hard error, but it appears to give the wrong
>answer (presumably because the is_convertible check fails due to E
>being incomplete). This may need to be handled explicitly?

This seems to work, at least until PR 89025 is fixed (because you
can't currently refer to an incomplete scoped enum type).

Tested powerpc64le-linux, pushed to trunk.



-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch.txt
Type: text/x-patch
Size: 4625 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/libstdc++/attachments/20210408/42eaf616/attachment.bin>


More information about the Libstdc++ mailing list