diff options
author | Jonathan Wakely <jwakely@redhat.com> | 2024-11-14 14:54:57 +0000 |
---|---|---|
committer | Jonathan Wakely <redi@gcc.gnu.org> | 2024-11-14 15:39:03 +0000 |
commit | dec2158b2c39285a561a035ca383128c5c41ecf0 (patch) | |
tree | 15c57a9f54e5d1e65e79f4be5f1baa141b55c758 | |
parent | e56d183c1590962a3029f84d411cb635e6611f1a (diff) | |
download | gcc-dec2158b2c39285a561a035ca383128c5c41ecf0.zip gcc-dec2158b2c39285a561a035ca383128c5c41ecf0.tar.gz gcc-dec2158b2c39285a561a035ca383128c5c41ecf0.tar.bz2 |
libstdc++: Use requires-clause for __normal_iterator constructor
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.
-rw-r--r-- | libstdc++-v3/include/bits/stl_iterator.h | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/libstdc++-v3/include/bits/stl_iterator.h b/libstdc++-v3/include/bits/stl_iterator.h index 8c86cb2..5ea901b 100644 --- a/libstdc++-v3/include/bits/stl_iterator.h +++ b/libstdc++-v3/include/bits/stl_iterator.h @@ -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) |