Date: Mon, 28 Feb 2022 18:11:11 +0000
On Monday, February 28th, 2022 at 8:44 AM, Paolo Di Giglio via Std-Proposals <std-proposals_at_[hidden]> wrote:
> I'd like to propose a specialization of function template std::get for
>
> C-style arrays. A simple two-liner would provide compile-time catching
>
> of out-of-bound array accesses (please note we already have this check
>
> for the std::array specialization):
>
> template <std::size_t Idx, typename T, std::size_t N>
>
> constexpr T& get(T (&arr)[N]) noexcept
>
> {
>
> static_assert(Idx < N, "Index out of bounds");
>
> return arr[Idx];
>
> }
I had that thought back in
Use array as a tuple - 4BSD (miator.net)
It is worth noticing that the latter addedstructured binding has special rules forarrays, so enabling tuple-interface onarrays may cause some confusion.
> I'd like to propose a specialization of function template std::get for
>
> C-style arrays. A simple two-liner would provide compile-time catching
>
> of out-of-bound array accesses (please note we already have this check
>
> for the std::array specialization):
>
> template <std::size_t Idx, typename T, std::size_t N>
>
> constexpr T& get(T (&arr)[N]) noexcept
>
> {
>
> static_assert(Idx < N, "Index out of bounds");
>
> return arr[Idx];
>
> }
I had that thought back in
Use array as a tuple - 4BSD (miator.net)
It is worth noticing that the latter addedstructured binding has special rules forarrays, so enabling tuple-interface onarrays may cause some confusion.
-- Zhihao Yuan, ID lichray The best way to predict the future is to invent it. _______________________________________________
Received on 2022-02-28 18:11:16