[llvm] a666d1f - Fixed build with C++20 standard (#169772)

via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 23 09:51:42 PST 2025


Author: Vedran Miletić
Date: 2025-12-23T12:51:38-05:00
New Revision: a666d1fd9a1b06e9122531b7e139471f67c1a1d8

URL: https://github.com/llvm/llvm-project/commit/a666d1fd9a1b06e9122531b7e139471f67c1a1d8
DIFF: https://github.com/llvm/llvm-project/commit/a666d1fd9a1b06e9122531b7e139471f67c1a1d8.diff

LOG: Fixed build with C++20 standard (#169772)

Building LLVM with CMAKE_CXX_STANDARD set to 20 fails since the iterator
facade is not fully compatible with C++20. To make it compatible,
specific operator overloads have to be constrained.

Overload for operator- in ADT iterator is now constrained with concept
BaseT::IsRandomAccess.

Patch by Jonathan Wakely.

Fixes #139072.

---------

Co-authored-by: A. Jiang <de34 at live.cn>
Co-authored-by: Jakub Kuderski <kubakuderski at gmail.com>

Added: 
    

Modified: 
    llvm/include/llvm/ADT/iterator.h

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/ADT/iterator.h b/llvm/include/llvm/ADT/iterator.h
index 6f0c42fe08bec..c0495e24893fb 100644
--- a/llvm/include/llvm/ADT/iterator.h
+++ b/llvm/include/llvm/ADT/iterator.h
@@ -267,6 +267,8 @@ class iterator_adaptor_base
     return *static_cast<DerivedT *>(this);
   }
   using BaseT::operator-;
+  template <bool Enabled = BaseT::IsRandomAccess,
+            typename = std::enable_if_t<Enabled>>
   
diff erence_type operator-(const DerivedT &RHS) const {
     static_assert(
         BaseT::IsRandomAccess,


        


More information about the llvm-commits mailing list