C++ Logo

std-proposals

Advanced search

Re: "Union types" syntactic sugar

From: Sebastian Büttner <sebastian.buettner_at_[hidden]>
Date: Wed, 4 Mar 2020 18:50:24 +0100
On 04.03.20 18:34, Barry Revzin wrote:
> On Wed, Mar 4, 2020, 11:11 AM Sebastian Büttner via Std-Proposals
> <std-proposals_at_[hidden]
> <mailto:std-proposals_at_[hidden]>> wrote:
>
> Sure! You can do this (you were missing the "auto" of the
> placeholder-type-specifier):
>
> voidf(std::basic_string<any_of<char, uint8_t> auto> x);
>
>
> This one is not valid in C++20, but hopefully will become valid in
> C++23 (although the auto would go outside the template -
> basic_string<Concept> auto)
>
> Barry

Hi Barry,

why not? At least the grammar allows for it, is there any paragraph that
disallows this (I admit I did only lookup the grammar, which often
allows more than the actual language)?

    type-id <- type-specifier-seq <- type-specifier <-
    simple-type-specifier <- placeholder-type-specifier <-
    type-constraint_opt auto

    https://eel.is/c++draft/temp.arg.type#1
    https://eel.is/c++draft/dcl.type#nt:type-specifier-seq
    https://eel.is/c++draft/dcl.type#nt:type-specifier
    https://eel.is/c++draft/dcl.type#nt:simple-type-specifier
    https://eel.is/c++draft/dcl.type#nt:placeholder-type-specifier

Also: why would auto be placed outside of the template argument?

Thanks!

Sebastian


Received on 2020-03-04 11:53:15