[libcxx-commits] [libcxx] [libc++] Simplify the implementation of the pointer aliases in allocator_traits (PR #127079)
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Feb 26 08:19:08 PST 2025
================
@@ -49,50 +49,38 @@ using __pointer_member _LIBCPP_NODEBUG = typename _Tp::pointer;
template <class _Tp, class _Alloc>
using __pointer _LIBCPP_NODEBUG = __detected_or_t<_Tp*, __pointer_member, __libcpp_remove_reference_t<_Alloc> >;
-// __const_pointer
-_LIBCPP_ALLOCATOR_TRAITS_HAS_XXX(__has_const_pointer, const_pointer);
-template <class _Tp, class _Ptr, class _Alloc, bool = __has_const_pointer<_Alloc>::value>
-struct __const_pointer {
- using type _LIBCPP_NODEBUG = typename _Alloc::const_pointer;
-};
-template <class _Tp, class _Ptr, class _Alloc>
-struct __const_pointer<_Tp, _Ptr, _Alloc, false> {
+template <class _Ptr, class _Alloc, class _Tp, template <class> class _Alias, class = void>
----------------
ldionne wrote:
I feel like this order of arguments is kinda confusing. IMO this would make more sense:
```c++
// This trait returns _Alias<_Alloc> if that is well-formed, and _Ptr rebound to _Tp otherwise.
template <class _Alloc, template <class> class _Alias, class _Ptr, class _Tp>
```
The usage will now look like
```c++
__rebind_or_alias_pointer<_Alloc, __const_pointer_member, _Ptr, const _Tp>
```
https://github.com/llvm/llvm-project/pull/127079
More information about the libcxx-commits
mailing list