diff --git a/libstdc++-v3/include/debug/helper_functions.h b/libstdc++-v3/include/debug/helper_functions.h index b9771034bf3..b058408a1e3 100644 --- a/libstdc++-v3/include/debug/helper_functions.h +++ b/libstdc++-v3/include/debug/helper_functions.h @@ -292,7 +292,7 @@ namespace __gnu_debug template - bool + _GLIBCXX20_CONSTEXPR bool __can_advance(const _Safe_iterator<_Iterator, _Sequence, _Category>&, _Size); @@ -304,7 +304,7 @@ namespace __gnu_debug template - bool + _GLIBCXX20_CONSTEXPR bool __can_advance(const _Safe_iterator<_Iterator, _Sequence, _Category>&, const std::pair<_Diff, _Distance_precision>&, int); diff --git a/libstdc++-v3/include/debug/safe_iterator.h b/libstdc++-v3/include/debug/safe_iterator.h index 80ed9570ecb..ef61ab5e026 100644 --- a/libstdc++-v3/include/debug/safe_iterator.h +++ b/libstdc++-v3/include/debug/safe_iterator.h @@ -1145,21 +1145,33 @@ namespace __gnu_debug template + _GLIBCXX20_CONSTEXPR inline bool __can_advance(const _Safe_iterator<_Iterator, _Sequence, _Category>& __it, _Size __n) - { return __it._M_can_advance(__n); } + { + if (std::__is_constant_evaluated()) + return true; + + return __it._M_can_advance(__n); + } template + _GLIBCXX20_CONSTEXPR inline bool __can_advance(const _Safe_iterator<_Iterator, _Sequence, _Category>& __it, const std::pair<_Diff, _Distance_precision>& __dist, int __way) - { return __it._M_can_advance(__dist, __way); } + { + if (std::__is_constant_evaluated()) + return true; + + return __it._M_can_advance(__dist, __way); + } template - _Iterator + _GLIBCXX20_CONSTEXPR _Iterator __base(const _Safe_iterator<_Iterator, _Sequence, std::random_access_iterator_tag>& __it) { return __it.base(); }