Date: Mon, 28 Feb 2022 20:19:30 +0200
I am really surprised this not in the standard
On Mon, Feb 28, 2022 at 8:11 PM Zhihao Yuan via Std-Proposals <
std-proposals_at_[hidden]> wrote:
> 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)
> <https://blog.miator.net/post/39362111475/use-array-as-a-tuple>
>
> It is worth noticing that the latter added
> structured binding has special rules for
> arrays, so enabling tuple-interface on
> arrays may cause some confusion.
>
> --
> Zhihao Yuan, ID lichray
> The best way to predict the future is to invent it.
> _______________________________________________
>
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>
On Mon, Feb 28, 2022 at 8:11 PM Zhihao Yuan via Std-Proposals <
std-proposals_at_[hidden]> wrote:
> 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)
> <https://blog.miator.net/post/39362111475/use-array-as-a-tuple>
>
> It is worth noticing that the latter added
> structured binding has special rules for
> arrays, so enabling tuple-interface on
> arrays may cause some confusion.
>
> --
> Zhihao Yuan, ID lichray
> The best way to predict the future is to invent it.
> _______________________________________________
>
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>
Received on 2022-02-28 18:20:09