[libcxx-commits] [libcxx] [libc++] Implement LWG4245: Operators that interact with counted_iterator and default_sentinel_t should be noexcept (PR #235445)

Lucas Mellone via libcxx-commits libcxx-commits at lists.llvm.org
Sun Oct 25 09:42:01 PDT 2026


================
@@ -77,6 +77,11 @@ constexpr bool test() {
     {
       std::counted_iterator iter(cpp20_input_iterator<int*>(buffer), 8);
 
+      static_assert(noexcept(iter == std::default_sentinel));
----------------
lknknm wrote:

LGTM. The only thing I would suggest is adding a comment on top of these blocks like:

```suggestion
     // LWG4245: "Operators that interact with counted_iterator and default_sentinel_t should be noexcept"
      static_assert(noexcept(iter == std::default_sentinel));
```

I've been personally trying to make the LWG test scenarios explicit whenever possible, but it's just an opinionated point of view.

I'd also assess if we should move it to another function called `test_lwg4245` more or less the same as we did in https://github.com/llvm/llvm-project/blob/main/libcxx/test/std/iterators/iterator.primitives/range.iter.ops/range.iter.ops.distance/iterator_sentinel.pass.cpp#L228 but overall this is a question to @frederick-vs-ja and @H-G-Hristov .

Thanks!

https://github.com/llvm/llvm-project/pull/235445


More information about the libcxx-commits mailing list