Date: Mon, 17 Nov 2025 15:37:27 +0800
This can now be easily done by providing an `operator[] ` that takes an
`integral-constant-like` for `tuple` :
std::tuple t{'a', 0.42, 100};
t[std::cw<0>] = 'b';
t[std::cw<1>] = 0.0;
t[std::cw<2>] = 5;
And the implementation can be simplified by duducing this.
Therefore, is providing an operator[] for a tuple more desirable feature
than the this original proposal?
Jonathan Wakely via Std-Proposals <std-proposals_at_[hidden]> 於
2025年11月17日 週一 下午2:30寫道:
>
>
> On Sun, 16 Nov 2025, 17:18 Bjorn Reese via Std-Proposals, <
> std-proposals_at_[hidden]> wrote:
>
>> On 11/16/25 16:42, Hewill Kang via Std-Proposals wrote:
>>
>> > I think this might be a bit far-fetched, because it changes the
>> > long-standing expected use case of operator[]. More precisely, it
>> > provides a more complex overload for operator[]. I don't know if it's
>> > worth it.
>>
>> Recall that we already have a special syntax with array bound checks for
>> tuple-like classes:
>>
>> std::array<int, 4> a{};
>> auto v = std::get<42>(a);
>>
>
>
> Yes, but if we could have supported accessing tuples as tup[N] I think
> most people would have preferred that!
>
> The get<N> syntax is a less-than-ideal hack.
>
>
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>
`integral-constant-like` for `tuple` :
std::tuple t{'a', 0.42, 100};
t[std::cw<0>] = 'b';
t[std::cw<1>] = 0.0;
t[std::cw<2>] = 5;
And the implementation can be simplified by duducing this.
Therefore, is providing an operator[] for a tuple more desirable feature
than the this original proposal?
Jonathan Wakely via Std-Proposals <std-proposals_at_[hidden]> 於
2025年11月17日 週一 下午2:30寫道:
>
>
> On Sun, 16 Nov 2025, 17:18 Bjorn Reese via Std-Proposals, <
> std-proposals_at_[hidden]> wrote:
>
>> On 11/16/25 16:42, Hewill Kang via Std-Proposals wrote:
>>
>> > I think this might be a bit far-fetched, because it changes the
>> > long-standing expected use case of operator[]. More precisely, it
>> > provides a more complex overload for operator[]. I don't know if it's
>> > worth it.
>>
>> Recall that we already have a special syntax with array bound checks for
>> tuple-like classes:
>>
>> std::array<int, 4> a{};
>> auto v = std::get<42>(a);
>>
>
>
> Yes, but if we could have supported accessing tuples as tup[N] I think
> most people would have preferred that!
>
> The get<N> syntax is a less-than-ideal hack.
>
>
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>
Received on 2025-11-17 07:37:41
