[libcxx-commits] [libcxx] [libc++] LWG 3821 uses_allocator_construction_args should have overload for pair-like (PR #66939)
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Sep 21 05:22:07 PDT 2023
================
@@ -139,23 +157,33 @@ template <class _Tp>
inline constexpr bool __convertible_to_const_pair_ref =
decltype(__uses_allocator_detail::__convertible_to_const_pair_ref_impl<_Tp>(0))::value;
+# if _LIBCPP_STD_VER >= 23
+template <class _Tp, class _Up>
+inline constexpr bool __uses_allocator_constraints =
+ __is_cv_std_pair<_Tp> &&
+ (__is_specialization_of_subrange<remove_cvref_t<_Up>>::value ||
+ (!__pair_like<_Up> && !__convertible_to_const_pair_ref<_Up>));
+# else
+template <class _Tp, class _Up>
+inline constexpr bool __uses_allocator_constraints = __is_cv_std_pair<_Tp> && !__convertible_to_const_pair_ref<_Up>;
+# endif
+
} // namespace __uses_allocator_detail
-template <
- class _Pair,
- class _Alloc,
- class _Type,
- __enable_if_t<__is_std_pair<_Pair> && !__uses_allocator_detail::__convertible_to_const_pair_ref<_Type>, int> = 0>
+template < class _Pair,
+ class _Alloc,
+ class _Type,
+ __enable_if_t<__uses_allocator_detail::__uses_allocator_constraints<_Pair, _Type>, int> = 0>
_LIBCPP_HIDE_FROM_ABI constexpr auto
__uses_allocator_construction_args(const _Alloc& __alloc, _Type&& __value) noexcept;
template <class _Type, class _Alloc, class... _Args>
_LIBCPP_HIDE_FROM_ABI constexpr _Type __make_obj_using_allocator(const _Alloc& __alloc, _Args&&... __args);
-template <class _Pair,
- class _Alloc,
- class _Type,
- __enable_if_t<__is_std_pair<_Pair> && !__uses_allocator_detail::__convertible_to_const_pair_ref<_Type>, int>>
+template < class _Pair,
+ class _Alloc,
+ class _Type,
+ __enable_if_t< __uses_allocator_detail::__uses_allocator_constraints<_Pair, _Type>, int>>
----------------
ldionne wrote:
```suggestion
__enable_if_t< __uses_allocator_detail::__uses_allocator_constraints<_Pair, _Type>, int> = 0>
```
https://github.com/llvm/llvm-project/pull/66939
More information about the libcxx-commits
mailing list