C++ pattern matching is coming

ryuukk_ ryuukk.dev at gmail.com
Fri Oct 28 15:56:51 UTC 2022


On Friday, 28 October 2022 at 15:45:51 UTC, Nick Treleaven wrote:
> On Friday, 28 October 2022 at 15:29:15 UTC, ryuukk_ wrote:
>> On Friday, 28 October 2022 at 14:49:28 UTC, Nick Treleaven 
>> wrote:
>>> On Friday, 28 October 2022 at 14:47:27 UTC, ryuukk_ wrote:
>>>> On Friday, 28 October 2022 at 14:43:54 UTC, Nick Treleaven 
>>>> wrote:
>>>>> Has C or C++ actually added sum types to their standards?
>>>>
>>>> It was proposed and feedback was favorable, it's only just a 
>>>> matter of when now
>>>
>>> Do you have a link? I saw the circle compiler extension and 
>>> feedback wasn't all favourable. Standardising something is 
>>> long and arduous.
>>
>> Here is the latest revision i could find
>>
>> https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/p1371r3.pdf
>>
>>
>> And Bjarne Stroustrup thoughts
>>
>> https://www.open-std.org/JTC1/SC22/WG21/docs/papers/2021/p2411r0.pdf
>
> That's pattern matching (I probably confused things mentioning 
> circle). Presumably sum types would still be a library feature 
> in C++.


You didn't read #10 Future Work

> 10.1 Language Support for Variant
The design of this proposal also accounts for a potential 
language support for variant. It achieves this by keeping
the alternative pattern flexible for new extensions via < 
new_entity > pattern.
> Consider an extension to union that allows it to be tagged by 
> an integral, and has proper lifetime management
such that the active alternative need not be destroyed manually.


More information about the Digitalmars-d mailing list