Date: Wed, 4 Mar 2020 18:09:49 +0100
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 works because "type-constraint auto" is a valid
placeholder-type-specifier (which is a simple-type-specifier) and those
are permitted as type-ids for a template type parameter (which is this
case):
For completness: 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
On 04.03.20 17:29, Michał Piotr Gawron via Std-Proposals wrote:
> On 04.03.2020 15:23, Sebastian Büttner via Std-Proposals wrote:
>> What's wrong with that (sorry for the terrible name):
>>
>> template<typenameT, typename... Us>
>> conceptany_of = (std::is_same_v<T, Us> || ...);
>>
>> voidf(any_of<char, uint8_t> autox);
>>
>> template<any_of<char, uint8_t> T>
>> voidf(std::basic_string<T> x);
> Ah, it looks like I could use this, it's quite readable to me. (I'm not
> very familiar with concepts yet.)
>
> Is there a way to have the std::basic_string<> version that would be
> more similar to this?
>
> void f (std::basic_string<any_of<char, uint8_t>> x);
>
> ?
>
placeholder-type-specifier):
voidf(std::basic_string<any_of<char, uint8_t> auto> x);
This works because "type-constraint auto" is a valid
placeholder-type-specifier (which is a simple-type-specifier) and those
are permitted as type-ids for a template type parameter (which is this
case):
For completness: 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
On 04.03.20 17:29, Michał Piotr Gawron via Std-Proposals wrote:
> On 04.03.2020 15:23, Sebastian Büttner via Std-Proposals wrote:
>> What's wrong with that (sorry for the terrible name):
>>
>> template<typenameT, typename... Us>
>> conceptany_of = (std::is_same_v<T, Us> || ...);
>>
>> voidf(any_of<char, uint8_t> autox);
>>
>> template<any_of<char, uint8_t> T>
>> voidf(std::basic_string<T> x);
> Ah, it looks like I could use this, it's quite readable to me. (I'm not
> very familiar with concepts yet.)
>
> Is there a way to have the std::basic_string<> version that would be
> more similar to this?
>
> void f (std::basic_string<any_of<char, uint8_t>> x);
>
> ?
>
Received on 2020-03-04 11:12:34