]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: Use requires-clause for __normal_iterator constructor
authorJonathan Wakely <jwakely@redhat.com>
Thu, 14 Nov 2024 14:54:57 +0000 (14:54 +0000)
committerJonathan Wakely <redi@gcc.gnu.org>
Thu, 14 Nov 2024 15:39:03 +0000 (15:39 +0000)
This is a very minor throughput optimization, to avoid instantiating
std::enable_if and std::is_convertible when concepts are available.

libstdc++-v3/ChangeLog:

* include/bits/stl_iterator.h (__normal_iterator): Replace
enable_if constraint with requires-clause.

libstdc++-v3/include/bits/stl_iterator.h

index 8c86cb214b228464d8cbc3a558ef75cf21261e6d..5ea901bf1f6c2f7701f1c6aa93e352fa513d7138 100644 (file)
@@ -1030,7 +1030,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
       typedef std::iterator_traits<_Iterator>          __traits_type;
 
-#if __cplusplus >= 201103L
+#if __cplusplus >= 201103L && ! defined __glibcxx_concepts
       template<typename _Iter>
        using __convertible_from
          = std::__enable_if_t<std::is_convertible<_Iter, _Iterator>::value>;
@@ -1060,7 +1060,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
       // Allow iterator to const_iterator conversion
 #if __cplusplus >= 201103L
+# ifdef __glibcxx_concepts
+      template<typename _Iter> requires std::is_convertible_v<_Iter, _Iterator>
+# else
       template<typename _Iter, typename = __convertible_from<_Iter>>
+# endif
        [[__gnu__::__always_inline__]]
        constexpr
        __normal_iterator(const __normal_iterator<_Iter, _Container>& __i)