C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Extension to std::tuples to allow runtime indexing.

From: Ville Voutilainen <ville.voutilainen_at_[hidden]>
Date: Sat, 18 Apr 2026 19:04:36 +0300
On Sat, 18 Apr 2026 at 18:53, Simon Schröder via Std-Proposals
<std-proposals_at_[hidden]> wrote:
> I wasn’t aware of this problem. Well, std::tuple is compile-time known. So, maybe (similarly to how std::tuple is immutably in its size) we could make it a const std::vector<std::variant>. Correct me if I’m wrong again: In this case operator[] would return a const std::variant& (making the returned variant const was what I was trying to achieve).

Correct:

constexpr const_reference operator[](size_type n) const;

Received on 2026-04-18 16:04:51