[libcxx-commits] [libcxx] [libc++] LWG 3821 uses_allocator_construction_args should have overload for pair-like (PR #66939)

via libcxx-commits libcxx-commits at lists.llvm.org
Thu Sep 21 14:00:47 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>>
----------------
huixie90 wrote:

> This meant that this specialization was never getting picked. If the tests were passing before this change, then there is some missing coverage.

If you scroll up,  the declaration  of the function  does have the default value 0.  you can't have default value twice.


https://github.com/llvm/llvm-project/pull/66939


More information about the libcxx-commits mailing list