forked from OSchip/llvm-project
40a6be4346
Some types that inherit from `view_interface` do not meet the preconditions. This came up during discussion in https://reviews.llvm.org/D112631. Currently, the behavior is IFNDR, but the preconditions can be easily checked, so let's do so. In particular, we know each public member function calls the `__derived()` private function, so we can do the check there. We intentionally do it as a `static_assert` instead of a `requires` clause to avoid hard erroring in some cases, such as with incomplete types. An example hard error is: ``` llvm-project/build/include/c++/v1/__ranges/view_interface.h:48:14: note: because 'sizeof(_Tp)' would be invalid: invalid application of 'sizeof' to an incomplete type 'MoveOnlyForwardRange' requires { sizeof(_Tp); } && ^ llvm-project/build/include/c++/v1/__ranges/view_interface.h:73:26: error: no matching member function for call to '__derived' return ranges::begin(__derived()) == ranges::end(__derived()); ^~~~~~~~~ llvm-project/libcxx/test/std/ranges/range.utility/view.interface/view.interface.pass.cpp:187:31: note: in instantiation of function template specialization 'std::ranges::view_interface<MoveOnlyForwardRange>::empty<Mov eOnlyForwardRange>' requested here assert(!std::move(moveOnly).empty()); ``` Reviewed By: Quuxplusone, Mordante, #libc Differential Revision: https://reviews.llvm.org/D112665 |
||
---|---|---|
.. | ||
access.h | ||
all.h | ||
common_view.h | ||
concepts.h | ||
copyable_box.h | ||
counted.h | ||
dangling.h | ||
data.h | ||
drop_view.h | ||
empty.h | ||
empty_view.h | ||
enable_borrowed_range.h | ||
enable_view.h | ||
iota_view.h | ||
join_view.h | ||
non_propagating_cache.h | ||
range_adaptor.h | ||
ref_view.h | ||
reverse_view.h | ||
single_view.h | ||
size.h | ||
subrange.h | ||
take_view.h | ||
transform_view.h | ||
view_interface.h |