Issue |
81455
|
Summary |
reverse iterator might not respect fancy pointers
|
Labels |
new issue
|
Assignees |
|
Reporter |
ilazaric
|
https://github.com/llvm/llvm-project/blob/f5399e89a27d8c64849a1631958952f4dfe14692/libcxx/include/__iterator/reverse_iterator.h#L135C1-L145C1
`return std::prev(current).operator->();`
If the `_Iter` type is a fancy pointer from an allocator, this _expression_ will reduce to a raw pointer since fancy pointers usually implement an `operator->` to a raw pointer
I think it's more appropriate for a fancy pointer to have alias `pointer` refer to itself rather than a raw pointer
It might make more sense (not sure if best though) to check if `_Iter` is same as the iterator pointer, kinda like:
`std::is_same_v<_Iter, std::iterator_traits<_Iter>::pointer>` in the `if constexpr` condition:
```
#if _LIBCPP_STD_VER >= 20
_LIBCPP_HIDE_FROM_ABI constexpr pointer operator->() const
requires is_pointer_v<_Iter> || requires(const _Iter __i) { __i.operator->(); }
{
if constexpr (std::is_same_v<_Iter, std::iterator_traits<_Iter>::pointer>) {
return std::prev(current);
} else {
return std::prev(current).operator->();
}
}
#else
```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs