C++ Logo

std-proposals

Advanced search

Re: [std-proposals] compile-time safety operator[]?

From: Bjorn Reese <breese_at_[hidden]>
Date: Sun, 16 Nov 2025 18:18:27 +0100
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);

Received on 2025-11-16 17:18:36