[libc++] Simplify std::ranges::subrange
authorLouis Dionne <ldionne.2@gmail.com>
Thu, 23 Sep 2021 22:09:17 +0000 (18:09 -0400)
committerLouis Dionne <ldionne.2@gmail.com>
Tue, 28 Sep 2021 21:34:01 +0000 (17:34 -0400)
commit86df5a2fa832cdb42928c7a6670eb927f04b98d4
tree012a88572ce8ce72a8f636524d754ff75bb91bbf
parent952f030fe6ade193ead8f23a7654cf8d2c7aa3df
[libc++] Simplify std::ranges::subrange

Instead of using a base class to store the members and the optional
size, use [[no_unique_address]] to achieve the same thing without
needing a base class.

Also, as a fly-by:
- Change subrange from struct to class (per the standard)
- Improve the diagnostic for when one doesn't provide a size to the ctor of a sized subrange
- Replace this->member by just member since it's not in a dependent base anymore

This change would be an ABI break due to [[no_unique_address]], but we
haven't shipped ranges anywhere yet, so this shouldn't affect anyone.

Differential Revision: https://reviews.llvm.org/D110370
libcxx/include/__ranges/subrange.h
libcxx/test/std/ranges/range.utility/range.subrange/ctor.default.pass.cpp [new file with mode: 0644]