[libc++] LWG4012: common_view::begin/end are missing the simple-view check (#153674)

close #105320
This commit is contained in:
Nhat Nguyen 2026-02-08 20:17:30 -05:00 committed by GitHub
parent 9892b2a7b5
commit 9a60b2fa0c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 46 additions and 1 deletions

View File

@ -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>`__",""

1 Issue # Issue Name Meeting Status First released version GitHub issue Notes
46 `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>`__
47 `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>`__
48 `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>`__
49 `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>`__
50 `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>`__
51 `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>`__
52 `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>`__

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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