Date: Wed, 28 Sep 2022 10:12:57 -0400
On Wed, Sep 28, 2022 at 10:06 AM Sébastien Bini via Std-Proposals
<std-proposals_at_[hidden]> wrote:
>
> How about a syntax similar to that of parameters then?
>
> template <class T> T var = foo();
> template <class K, class V> std::pair<K const, V>& kv = *map.begin(); // or [k, v]?
> template <std::copyable T, auto I> std::array<T, I> arr = getArr();
> template <std::size_t... I> [[maybe_unused]] std::index_sequence<I...> seq = std::index_sequence_for<Args...>();
>
> Then we don't need to reinvent the syntax for parameters.
Let's re-examine the problem that people seem to want to solve.
My understanding was that the principal problem was that you want to
gain access to the actual typename that the placeholder deduction
syntax yields, and sticking a `using name = decltype(var_name);` is
both wordy and error-prone (I deliberately did that wrong, for
example).
The main reason people deduce types is because they don't want to have
to type out the full name of the type (or because it's already
mentioned in the initializing expression). So it seems to me that
injecting a bunch more words into such a declaration is...
counter-productive.
Yes, any of these declarations might be useful. But... are they really
*that* useful? So useful that we want to type out (and read) all of
that?
<std-proposals_at_[hidden]> wrote:
>
> How about a syntax similar to that of parameters then?
>
> template <class T> T var = foo();
> template <class K, class V> std::pair<K const, V>& kv = *map.begin(); // or [k, v]?
> template <std::copyable T, auto I> std::array<T, I> arr = getArr();
> template <std::size_t... I> [[maybe_unused]] std::index_sequence<I...> seq = std::index_sequence_for<Args...>();
>
> Then we don't need to reinvent the syntax for parameters.
Let's re-examine the problem that people seem to want to solve.
My understanding was that the principal problem was that you want to
gain access to the actual typename that the placeholder deduction
syntax yields, and sticking a `using name = decltype(var_name);` is
both wordy and error-prone (I deliberately did that wrong, for
example).
The main reason people deduce types is because they don't want to have
to type out the full name of the type (or because it's already
mentioned in the initializing expression). So it seems to me that
injecting a bunch more words into such a declaration is...
counter-productive.
Yes, any of these declarations might be useful. But... are they really
*that* useful? So useful that we want to type out (and read) all of
that?
Received on 2022-09-28 14:14:07