mirror of
https://forge.sourceware.org/marek/gcc.git
synced 2026-02-22 03:47:02 -05:00
libstdc++: Make more _Safe_iterator functions in constexpr in C++20.
This functions are indirectly called from flat_ containers operations (from preconditions check of lower_bound, upper_bound, ...) that were made constexpr by r16-6026-gbf9dd44a97400e, leading to test with in _GLIBCXX_DEBUG mode. For __can_advance we uncoditionally return true in constant evaluation, similary to __valid_range. The constexpr iterator will detect comparision of iterator to different ranges. libstdc++-v3/ChangeLog: * include/debug/helper_functions.h (__gnu_debug::__can_advance): Declare as _GLIBCXX20_CONSTEXPR. * include/debug/safe_iterator.h (__gnu_debug::__can_advance): Define as _GLIBCXX20_CONSTEXPR, and return true for constexpr evaluation. (__gnu_debug::__base): Define as _GLIBCXX20_CONSTEXPR.
This commit is contained in:
@@ -292,7 +292,7 @@ namespace __gnu_debug
|
||||
|
||||
template<typename _Iterator, typename _Sequence, typename _Category,
|
||||
typename _Size>
|
||||
bool
|
||||
_GLIBCXX20_CONSTEXPR bool
|
||||
__can_advance(const _Safe_iterator<_Iterator, _Sequence, _Category>&,
|
||||
_Size);
|
||||
|
||||
@@ -304,7 +304,7 @@ namespace __gnu_debug
|
||||
|
||||
template<typename _Iterator, typename _Sequence, typename _Category,
|
||||
typename _Diff>
|
||||
bool
|
||||
_GLIBCXX20_CONSTEXPR bool
|
||||
__can_advance(const _Safe_iterator<_Iterator, _Sequence, _Category>&,
|
||||
const std::pair<_Diff, _Distance_precision>&, int);
|
||||
|
||||
|
||||
@@ -1145,21 +1145,33 @@ namespace __gnu_debug
|
||||
|
||||
template<typename _Iterator, typename _Sequence, typename _Category,
|
||||
typename _Size>
|
||||
_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<typename _Iterator, typename _Sequence, typename _Category,
|
||||
typename _Diff>
|
||||
_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<typename _Iterator, typename _Sequence>
|
||||
_Iterator
|
||||
_GLIBCXX20_CONSTEXPR _Iterator
|
||||
__base(const _Safe_iterator<_Iterator, _Sequence,
|
||||
std::random_access_iterator_tag>& __it)
|
||||
{ return __it.base(); }
|
||||
|
||||
Reference in New Issue
Block a user