C++ Logo

std-discussion

Advanced search

Re: Possible std::ranges::subrange defect?

From: Keenan Horrigan <friedkeenan_at_[hidden]>
Date: Sat, 18 Sep 2021 01:57:50 +0000
I see, thank you for clearing this up.

‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐

On Friday, September 17th, 2021 at 6:57 PM, Jason McKesson via Std-Discussion <std-discussion_at_[hidden]> wrote:

> On Fri, Sep 17, 2021 at 7:21 PM Keenan Horrigan via Std-Discussion
>
> std-discussion_at_[hidden] wrote:
>
> > Hi, this is my first time really using a mailing list so apologies if I do anything wrong.
> >
> > I've been looking at std::ranges::subrange, and I think the "pair-like" concept used for converting to a pair-like type might be slightly broken? It requires std::tuple_size<T> to be derived from std::integral_constant<std::size_t, 2>, but in the specification for structured binding, as far as I can tell, it only requires `std::tuple_size<T>::value` to be a "well-formed integral constant expression", with no requirement for being related to std::integral_constant. Is it intentional that this "pair-like" concept is stricter than the requirements for structured binding?
>
> [tuple.helper]/1 specifically states:
>
> > All specializations of tuple_­size meet the Cpp17UnaryTypeTrait requirements ([meta.rqmts]) with a base characteristic of integral_­constant<size_­t, N> for some N.
>
> As such, the requirements from structured binding are technically too
>
> loose. It's not really a defect, since doing the minimum required by
>
> structured binding would break the [tuple.helper]/1 requirement, so
>
> it'd still be UB.
>
> This is similar to how range-based `for` doesn't verify that the
>
> returns of `begin/end` are iterators; it simply specifies the specific
>
> things it will do with them.
> -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>
> Std-Discussion mailing list
>
> Std-Discussion_at_[hidden]
>
> https://lists.isocpp.org/mailman/listinfo.cgi/std-discussion

Received on 2021-09-17 20:57:58