[llvm] Fixed build with C++20 standard (PR #169772)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 27 00:05:06 PST 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-adt
Author: Vedran Miletić (vedranmiletic)
<details>
<summary>Changes</summary>
Overload for operator- in ADT iterator is now constrained with concept BaseT::IsRandomAccess.
Patch by Jonathan Wakely.
Fixes #<!-- -->139072.
---
Full diff: https://github.com/llvm/llvm-project/pull/169772.diff
1 Files Affected:
- (modified) llvm/include/llvm/ADT/iterator.h (+5-1)
``````````diff
diff --git a/llvm/include/llvm/ADT/iterator.h b/llvm/include/llvm/ADT/iterator.h
index 6f0c42fe08bec..f55f9d4a3e7f2 100644
--- a/llvm/include/llvm/ADT/iterator.h
+++ b/llvm/include/llvm/ADT/iterator.h
@@ -267,7 +267,11 @@ class iterator_adaptor_base
return *static_cast<DerivedT *>(this);
}
using BaseT::operator-;
- difference_type operator-(const DerivedT &RHS) const {
+ difference_type operator-(const DerivedT &RHS) const
+#ifdef __cpp_concepts
+ requires(bool(BaseT::IsRandomAccess))
+#endif
+ {
static_assert(
BaseT::IsRandomAccess,
"The '-' operator is only defined for random access iterators.");
``````````
</details>
https://github.com/llvm/llvm-project/pull/169772
More information about the llvm-commits
mailing list