[libc++] LWG4012: common_view::begin/end are missing the simple-view check (#153674)
close #105320
This commit is contained in:
parent
9892b2a7b5
commit
9a60b2fa0c
@ -46,7 +46,7 @@
|
||||
"`LWG3975 <https://wg21.link/LWG3975>`__","Specializations of ``basic_format_context`` should not be permitted","2024-03 (Tokyo)","|Nothing To Do|","","`#105317 <https://github.com/llvm/llvm-project/issues/105317>`__",""
|
||||
"`LWG3984 <https://wg21.link/LWG3984>`__","``ranges::to``'s recursion branch may be ill-formed","2024-03 (Tokyo)","|Complete|","19","`#105318 <https://github.com/llvm/llvm-project/issues/105318>`__",""
|
||||
"`LWG4011 <https://wg21.link/LWG4011>`__","""`Effects`: Equivalent to return"" in ``[span.elem]``","2024-03 (Tokyo)","|Nothing To Do|","","`#105319 <https://github.com/llvm/llvm-project/issues/105319>`__",""
|
||||
"`LWG4012 <https://wg21.link/LWG4012>`__","``common_view::begin/end`` are missing the ``simple-view`` check","2024-03 (Tokyo)","","","`#105320 <https://github.com/llvm/llvm-project/issues/105320>`__",""
|
||||
"`LWG4012 <https://wg21.link/LWG4012>`__","``common_view::begin/end`` are missing the ``simple-view`` check","2024-03 (Tokyo)","|Complete|","23","`#105320 <https://github.com/llvm/llvm-project/issues/105320>`__",""
|
||||
"`LWG4013 <https://wg21.link/LWG4013>`__","``lazy_split_view::outer-iterator::value_type`` should not provide default constructor","2024-03 (Tokyo)","","","`#105321 <https://github.com/llvm/llvm-project/issues/105321>`__",""
|
||||
"`LWG4016 <https://wg21.link/LWG4016>`__","container-insertable checks do not match what container-inserter does","2024-03 (Tokyo)","|Complete|","20","`#105322 <https://github.com/llvm/llvm-project/issues/105322>`__",""
|
||||
"`LWG4023 <https://wg21.link/LWG4023>`__","Preconditions of ``std::basic_streambuf::setg/setp``","2024-03 (Tokyo)","|Complete|","19","`#105323 <https://github.com/llvm/llvm-project/issues/105323>`__",""
|
||||
|
||||
|
@ -51,6 +51,12 @@ constexpr bool test() {
|
||||
assert(begin == std::ranges::begin(view));
|
||||
}
|
||||
|
||||
{
|
||||
NonSimpleNonCommonView view{buf, buf + 8};
|
||||
std::ranges::common_view<NonSimpleNonCommonView> common(view);
|
||||
static_assert(!std::is_same_v<decltype(common.begin()), decltype(std::as_const(common).begin())>);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@ -39,6 +39,12 @@ constexpr bool test() {
|
||||
assert(base(end) == buf + 8);
|
||||
}
|
||||
|
||||
{
|
||||
NonSimpleNonCommonView view{buf, buf + 8};
|
||||
std::ranges::common_view<NonSimpleNonCommonView> common(view);
|
||||
static_assert(!std::is_same_v<decltype(common.end()), decltype(std::as_const(common).end())>);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@ -90,4 +90,37 @@ struct NonCommonView : std::ranges::view_base {
|
||||
static_assert( std::ranges::view<NonCommonView>);
|
||||
static_assert(!std::ranges::common_range<NonCommonView>);
|
||||
|
||||
template <class T>
|
||||
concept HasConstBegin = requires(const T& ct) { ct.begin(); };
|
||||
|
||||
template <class T>
|
||||
concept HasBegin = requires(T& t) { t.begin(); };
|
||||
|
||||
template <class T>
|
||||
concept HasConstAndNonConstBegin = HasConstBegin<T> && requires(T& t, const T& ct) {
|
||||
requires !std::same_as<decltype(t.begin()), decltype(ct.begin())>;
|
||||
};
|
||||
|
||||
template <class T>
|
||||
concept HasOnlyNonConstBegin = HasBegin<T> && !HasConstBegin<T>;
|
||||
|
||||
template <class T>
|
||||
concept HasOnlyConstBegin = HasConstBegin<T> && !HasConstAndNonConstBegin<T>;
|
||||
|
||||
struct NonSimpleNonCommonView : std::ranges::view_base {
|
||||
int* begin_;
|
||||
int* end_;
|
||||
constexpr explicit NonSimpleNonCommonView(int* b, int* e) : begin_(b), end_(e) {}
|
||||
constexpr auto begin() const { return static_cast<const int*>(begin_); }
|
||||
constexpr auto end() const { return sentinel_wrapper<const int*>(end_); }
|
||||
constexpr int* begin() { return begin_; }
|
||||
constexpr auto end() { return sentinel_wrapper<int*>(end_); }
|
||||
};
|
||||
|
||||
static_assert(!HasOnlyNonConstBegin<std::ranges::common_view<NonSimpleNonCommonView>>);
|
||||
static_assert(!HasOnlyConstBegin<std::ranges::common_view<NonSimpleNonCommonView>>);
|
||||
static_assert(HasConstAndNonConstBegin<std::ranges::common_view<NonSimpleNonCommonView>>);
|
||||
static_assert(HasConstBegin<const std::ranges::common_view<NonSimpleNonCommonView>>);
|
||||
static_assert(HasOnlyConstBegin<const std::ranges::common_view<NonSimpleNonCommonView>>);
|
||||
|
||||
#endif // TEST_STD_RANGES_RANGE_ADAPTORS_RANGE_COMMON_VIEW_TYPES_H
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user