Date: Sat, 10 Jan 2026 14:31:06 +0100
Could you please offer a complete code example, with struct definitions etc.
as needed to show your point?
Jens
On 1/10/26 14:19, 徐 一凡 via Std-Proposals wrote:
> In P2688R5 pattern matching, variant-like and polymorphic types share the similar syntax to match alternatives or subtypes. This syntax is confusing for implying the type of alternatives to be a subtype. Also, this syntax makes it awkward to distinguish between the variant-like itself and its alternatives.
>
> In P2688R5, 'auto: let' is introduced to distinguish from 'let':
> auto: let alternative => //...
> let self => //...
>
> I suggest to treat alternative as subobject, which is far more straightforward:
> [let alternative] => //...
> let self => //...
>
> It can also be applied to pointer-like types such as optional, free from reusing '?':
> [let some] => //...
> nullptr => //...
> nullopt => //...
>
> The reason for the new syntax is that an alternative or a pointed-to is a distinct object beneath the matched object, rather than just a different interpretation of the same object. The old syntax should be only applied to type matching which can be performed through built-in casts.
>
as needed to show your point?
Jens
On 1/10/26 14:19, 徐 一凡 via Std-Proposals wrote:
> In P2688R5 pattern matching, variant-like and polymorphic types share the similar syntax to match alternatives or subtypes. This syntax is confusing for implying the type of alternatives to be a subtype. Also, this syntax makes it awkward to distinguish between the variant-like itself and its alternatives.
>
> In P2688R5, 'auto: let' is introduced to distinguish from 'let':
> auto: let alternative => //...
> let self => //...
>
> I suggest to treat alternative as subobject, which is far more straightforward:
> [let alternative] => //...
> let self => //...
>
> It can also be applied to pointer-like types such as optional, free from reusing '?':
> [let some] => //...
> nullptr => //...
> nullopt => //...
>
> The reason for the new syntax is that an alternative or a pointed-to is a distinct object beneath the matched object, rather than just a different interpretation of the same object. The old syntax should be only applied to type matching which can be performed through built-in casts.
>
Received on 2026-01-10 13:31:09
