libstdc++: Make structured bindings always work for subranges [PR 97512]
authorJonathan Wakely <jwakely@redhat.com>
Wed, 21 Oct 2020 13:40:54 +0000 (14:40 +0100)
committerJonathan Wakely <jwakely@redhat.com>
Wed, 21 Oct 2020 13:40:54 +0000 (14:40 +0100)
commita186ab670e97c4c3883d96506655c4621e7c5515
tree8936f3809ef772d3acbf611f1a729583ec8bca2e
parente957b86ca26f9a4e49acf625ed397e7dd05b0d66
libstdc++: Make structured bindings always work for subranges [PR 97512]

The definition of ranges::subrange was moved to the new
<bits/ranges_util.h> header so that it could be used in <algorithm>
without including the whole of <ranges>. However, the tuple-like support
that enables subrange to be used with structured bindings was left in
<ranges>. This is arguably conforming (to use a subrange you should
include <ranges>) but it's inconvenient and probably confusing.

This change makes the tuple-like support available whenever subrange
itself is available.

libstdc++-v3/ChangeLog:

PR libstdc++/97512
* include/bits/ranges_util.h (tuple_size<subrange>)
(tuple_element<I, cv subrange>): Move here from ...
* include/std/ranges: ... here.
* testsuite/std/ranges/subrange/97512.cc: New test.
libstdc++-v3/include/bits/ranges_util.h
libstdc++-v3/include/std/ranges
libstdc++-v3/testsuite/std/ranges/subrange/97512.cc [new file with mode: 0644]