Date: Tue, 18 Oct 2022 11:07:34 +0200
As I see `auto{T}` fist thing I think is "Most vexing parse" as it
looks exactly like `auto{t}`.
Probaby `auto<T>` would be better in this context, the only thing left
is check if `auto<` is currently forbidden because it would be
bit ironic if it has too "Most vexing parse" :)
pon., 17 paź 2022 o 18:55 Edward Catmur via Std-Proposals
<std-proposals_at_[hidden]> napisał(a):
>
> If you're still interested, Mike Spertus' P2677R0 looks similar to what you're after.
>
> https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p2677r0.pdf
>
> On Sat, 1 Oct 2022 at 11:14, Oleksandr Koval <oleksandr.koval.dev_at_[hidden]> wrote:
>>
>> That version of Edward looks 100% in line with current syntax but it's too verbose for me. It requires too much typing even for simple cases.
>> In the realm of universal template parameters I'd like to have:
>>
>> auto:[V<T>] v = std::vector<int>{}; // V = std::vector, T = int
>>
>> void f(const auto:[V]& v);
>>
>> auto:[T1, T2] [key, value] = get_pair();
>>
>> Why should we type those `template, class, int` inside [] if it's clear that it is a placeholder for a template parameter? Taking into account that this feature is supposed just to provide access to deduced type, I see no reason to allow it to constrain a kind of template parameters (type/non-type/template) or parameters themselves with concepts.
>>
>> Compiler can transform the above into:
>>
>> template<template auto V, template auto T>
>> void deduce_v(V<T>);
>>
>> On Fri, Sep 30, 2022 at 8:31 PM Edward Catmur via Std-Proposals <std-proposals_at_[hidden]> wrote:
>>>
>>> On Fri, 30 Sept 2022 at 17:38, Lénárd Szolnoki via Std-Proposals <std-proposals_at_[hidden]> wrote:
>>>>
>>>> Hi,
>>>>
>>>> One more syntax proposal that extends P1985's unkiversal template parameter: `template auto`
>>>>
>>>> 1. allow `template auto` in any deduced context, for example `vector<template auto> vec = get_vec();`
>>>> 2. use the syntax `template<class T> auto` to introduce the name `T`.
>>>
>>>
>>> Again, syntax. How on earth do you parse this? `template auto` in P1985's usage is fine, since it's just alternate for *template-parameter* (or *type-parameter*), with an alternation on the token `template` with *template-head* resolved immediately at the next token (`auto` vs. `<`). `vector<auto>` is similarly fine, since `auto` is already a *simple-type-specifier*, so that's just a semantic relaxation.
>>>
>>>> template<class T> auto x = foo()
>>>> vector<template<class V> auto> v = get_vec()
>>>>
>>>> Some extra stuff:
>>>> * Introducing a name is optional, you can use `template<class> auto` for a type placeholder, instead of a universal one
>>>> * you can have nttp or template placeholders too
>>>>
>>>> std::array<string, template<size_t arr_size> auto> arr = get_arr();
>>>>
>>>> A bit verbose compared to my previously proposed auto<class T>. Honestly, I like that more, but I could live with this.
>>>>
>>>> I definitely wouldn't want a syntax where you are required to immediately repeat the introduced name.
>>>
>>>
>>> Repeating the name means that you can specify its kind (type, class template, value, etc.) and easily see which names are introduced into scope.
>>>
>>> I really don't see the necessity to golf everything; C++ is already notoriously hard to parse and you want to make it even harder?
>>>
>>>>
>>>> Cheers,
>>>> Lénárd
>>>>
looks exactly like `auto{t}`.
Probaby `auto<T>` would be better in this context, the only thing left
is check if `auto<` is currently forbidden because it would be
bit ironic if it has too "Most vexing parse" :)
pon., 17 paź 2022 o 18:55 Edward Catmur via Std-Proposals
<std-proposals_at_[hidden]> napisał(a):
>
> If you're still interested, Mike Spertus' P2677R0 looks similar to what you're after.
>
> https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p2677r0.pdf
>
> On Sat, 1 Oct 2022 at 11:14, Oleksandr Koval <oleksandr.koval.dev_at_[hidden]> wrote:
>>
>> That version of Edward looks 100% in line with current syntax but it's too verbose for me. It requires too much typing even for simple cases.
>> In the realm of universal template parameters I'd like to have:
>>
>> auto:[V<T>] v = std::vector<int>{}; // V = std::vector, T = int
>>
>> void f(const auto:[V]& v);
>>
>> auto:[T1, T2] [key, value] = get_pair();
>>
>> Why should we type those `template, class, int` inside [] if it's clear that it is a placeholder for a template parameter? Taking into account that this feature is supposed just to provide access to deduced type, I see no reason to allow it to constrain a kind of template parameters (type/non-type/template) or parameters themselves with concepts.
>>
>> Compiler can transform the above into:
>>
>> template<template auto V, template auto T>
>> void deduce_v(V<T>);
>>
>> On Fri, Sep 30, 2022 at 8:31 PM Edward Catmur via Std-Proposals <std-proposals_at_[hidden]> wrote:
>>>
>>> On Fri, 30 Sept 2022 at 17:38, Lénárd Szolnoki via Std-Proposals <std-proposals_at_[hidden]> wrote:
>>>>
>>>> Hi,
>>>>
>>>> One more syntax proposal that extends P1985's unkiversal template parameter: `template auto`
>>>>
>>>> 1. allow `template auto` in any deduced context, for example `vector<template auto> vec = get_vec();`
>>>> 2. use the syntax `template<class T> auto` to introduce the name `T`.
>>>
>>>
>>> Again, syntax. How on earth do you parse this? `template auto` in P1985's usage is fine, since it's just alternate for *template-parameter* (or *type-parameter*), with an alternation on the token `template` with *template-head* resolved immediately at the next token (`auto` vs. `<`). `vector<auto>` is similarly fine, since `auto` is already a *simple-type-specifier*, so that's just a semantic relaxation.
>>>
>>>> template<class T> auto x = foo()
>>>> vector<template<class V> auto> v = get_vec()
>>>>
>>>> Some extra stuff:
>>>> * Introducing a name is optional, you can use `template<class> auto` for a type placeholder, instead of a universal one
>>>> * you can have nttp or template placeholders too
>>>>
>>>> std::array<string, template<size_t arr_size> auto> arr = get_arr();
>>>>
>>>> A bit verbose compared to my previously proposed auto<class T>. Honestly, I like that more, but I could live with this.
>>>>
>>>> I definitely wouldn't want a syntax where you are required to immediately repeat the introduced name.
>>>
>>>
>>> Repeating the name means that you can specify its kind (type, class template, value, etc.) and easily see which names are introduced into scope.
>>>
>>> I really don't see the necessity to golf everything; C++ is already notoriously hard to parse and you want to make it even harder?
>>>
>>>>
>>>> Cheers,
>>>> Lénárd
>>>>
Received on 2022-10-18 09:07:33