[libcxx-commits] [libcxx] [libc++] fixing missing forward declarations of uses_allocator_construction_args (PR #67044)

via libcxx-commits libcxx-commits at lists.llvm.org
Sun Oct 15 22:26:35 PDT 2023


https://github.com/phyBrackets updated https://github.com/llvm/llvm-project/pull/67044

>From b1f5e036207491b0090b60aa5e20a9469f0d39a8 Mon Sep 17 00:00:00 2001
From: Shivam Kunwar <shivam.kunwar at kdab.com>
Date: Thu, 21 Sep 2023 22:52:42 +0530
Subject: [PATCH 01/10] forward declarations for
 __uses_allocator_construction_args

---
 .../__memory/uses_allocator_construction.h    | 38 ++++++++++++++++---
 1 file changed, 32 insertions(+), 6 deletions(-)

diff --git a/libcxx/include/__memory/uses_allocator_construction.h b/libcxx/include/__memory/uses_allocator_construction.h
index 71ae5bcd323315b..90e4e5db7729977 100644
--- a/libcxx/include/__memory/uses_allocator_construction.h
+++ b/libcxx/include/__memory/uses_allocator_construction.h
@@ -58,6 +58,32 @@ __uses_allocator_construction_args(const _Alloc& __alloc, _Args&&... __args) noe
 }
 
 template <class _Pair, class _Alloc, class _Tuple1, class _Tuple2, __enable_if_t<__is_cv_std_pair<_Pair>, int> = 0>
+_LIBCPP_HIDE_FROM_ABI constexpr auto
+__uses_allocator_construction_args(const _Alloc& __a, piecewise_construct_t, _Tuple1&& __x, _Tuple2&& __y) noexcept;
+
+template <class _Pair, class _Alloc, __enable_if_t<__is_cv_std_pair<_Pair>, int> = 0>
+_LIBCPP_HIDE_FROM_ABI constexpr auto __uses_allocator_construction_args(const _Alloc&) noexcept;
+
+template <class _Pair, class _Alloc, class _Up, class _Vp, __enable_if_t<__is_cv_std_pair<_Pair>, int> = 0>
+_LIBCPP_HIDE_FROM_ABI constexpr auto __uses_allocator_construction_args(const _Alloc&, _Up&&, _Vp&&) noexcept;
+
+template <class _Pair, class _Alloc, class _Up, class _Vp, __enable_if_t<__is_cv_std_pair<_Pair>, int> = 0>
+_LIBCPP_HIDE_FROM_ABI constexpr auto
+__uses_allocator_construction_args(const _Alloc& __alloc, pair<_Up, _Vp>& __pair) noexcept;
+
+template <class _Pair, class _Alloc, class _Up, class _Vp, __enable_if_t<__is_cv_std_pair<_Pair>, int> = 0>
+_LIBCPP_HIDE_FROM_ABI constexpr auto
+__uses_allocator_construction_args(const _Alloc& __alloc, const pair<_Up, _Vp>& __pair) noexcept;
+
+template <class _Pair, class _Alloc, class _Up, class _Vp, __enable_if_t<__is_cv_std_pair<_Pair>, int> = 0>
+_LIBCPP_HIDE_FROM_ABI constexpr auto
+__uses_allocator_construction_args(const _Alloc& __alloc, pair<_Up, _Vp>&& __pair) noexcept;
+
+template <class _Pair, class _Alloc, class _Up, class _Vp, __enable_if_t<__is_cv_std_pair<_Pair>, int> = 0>
+_LIBCPP_HIDE_FROM_ABI constexpr auto
+__uses_allocator_construction_args(const _Alloc& __alloc, const pair<_Up, _Vp>&& __pair) noexcept;
+
+template <class _Pair, class _Alloc, class _Tuple1, class _Tuple2, __enable_if_t<__is_cv_std_pair<_Pair>, int>>
 _LIBCPP_HIDE_FROM_ABI constexpr auto __uses_allocator_construction_args(
     const _Alloc& __alloc, piecewise_construct_t, _Tuple1&& __x, _Tuple2&& __y) noexcept {
   return std::make_tuple(
@@ -76,12 +102,12 @@ _LIBCPP_HIDE_FROM_ABI constexpr auto __uses_allocator_construction_args(
           std::forward<_Tuple2>(__y)));
 }
 
-template <class _Pair, class _Alloc, __enable_if_t<__is_cv_std_pair<_Pair>, int> = 0>
+template <class _Pair, class _Alloc, __enable_if_t<__is_cv_std_pair<_Pair>, int>>
 _LIBCPP_HIDE_FROM_ABI constexpr auto __uses_allocator_construction_args(const _Alloc& __alloc) noexcept {
   return std::__uses_allocator_construction_args<_Pair>(__alloc, piecewise_construct, tuple<>{}, tuple<>{});
 }
 
-template <class _Pair, class _Alloc, class _Up, class _Vp, __enable_if_t<__is_cv_std_pair<_Pair>, int> = 0>
+template <class _Pair, class _Alloc, class _Up, class _Vp, __enable_if_t<__is_cv_std_pair<_Pair>, int>>
 _LIBCPP_HIDE_FROM_ABI constexpr auto
 __uses_allocator_construction_args(const _Alloc& __alloc, _Up&& __u, _Vp&& __v) noexcept {
   return std::__uses_allocator_construction_args<_Pair>(
@@ -92,7 +118,7 @@ __uses_allocator_construction_args(const _Alloc& __alloc, _Up&& __u, _Vp&& __v)
 }
 
 #  if _LIBCPP_STD_VER >= 23
-template <class _Pair, class _Alloc, class _Up, class _Vp, __enable_if_t<__is_cv_std_pair<_Pair>, int> = 0>
+template <class _Pair, class _Alloc, class _Up, class _Vp, __enable_if_t<__is_cv_std_pair<_Pair>, int>>
 _LIBCPP_HIDE_FROM_ABI constexpr auto
 __uses_allocator_construction_args(const _Alloc& __alloc, pair<_Up, _Vp>& __pair) noexcept {
   return std::__uses_allocator_construction_args<_Pair>(
@@ -100,14 +126,14 @@ __uses_allocator_construction_args(const _Alloc& __alloc, pair<_Up, _Vp>& __pair
 }
 #  endif
 
-template <class _Pair, class _Alloc, class _Up, class _Vp, __enable_if_t<__is_cv_std_pair<_Pair>, int> = 0>
+template <class _Pair, class _Alloc, class _Up, class _Vp, __enable_if_t<__is_cv_std_pair<_Pair>, int>>
 _LIBCPP_HIDE_FROM_ABI constexpr auto
 __uses_allocator_construction_args(const _Alloc& __alloc, const pair<_Up, _Vp>& __pair) noexcept {
   return std::__uses_allocator_construction_args<_Pair>(
       __alloc, piecewise_construct, std::forward_as_tuple(__pair.first), std::forward_as_tuple(__pair.second));
 }
 
-template <class _Pair, class _Alloc, class _Up, class _Vp, __enable_if_t<__is_cv_std_pair<_Pair>, int> = 0>
+template <class _Pair, class _Alloc, class _Up, class _Vp, __enable_if_t<__is_cv_std_pair<_Pair>, int>>
 _LIBCPP_HIDE_FROM_ABI constexpr auto
 __uses_allocator_construction_args(const _Alloc& __alloc, pair<_Up, _Vp>&& __pair) noexcept {
   return std::__uses_allocator_construction_args<_Pair>(
@@ -118,7 +144,7 @@ __uses_allocator_construction_args(const _Alloc& __alloc, pair<_Up, _Vp>&& __pai
 }
 
 #  if _LIBCPP_STD_VER >= 23
-template <class _Pair, class _Alloc, class _Up, class _Vp, __enable_if_t<__is_cv_std_pair<_Pair>, int> = 0>
+template <class _Pair, class _Alloc, class _Up, class _Vp, __enable_if_t<__is_cv_std_pair<_Pair>, int>>
 _LIBCPP_HIDE_FROM_ABI constexpr auto
 __uses_allocator_construction_args(const _Alloc& __alloc, const pair<_Up, _Vp>&& __pair) noexcept {
   return std::__uses_allocator_construction_args<_Pair>(

>From 4bcfabea021b8e8c3079df4c0df90bf0e805f2b8 Mon Sep 17 00:00:00 2001
From: Shivam Kunwar <shivam.kunwar at kdab.com>
Date: Fri, 22 Sep 2023 10:18:34 +0530
Subject: [PATCH 02/10] test coverage for the change

---
 .../uses_allocator_construction_args.pass.cpp          | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/libcxx/test/std/utilities/memory/allocator.uses/allocator.uses.construction/uses_allocator_construction_args.pass.cpp b/libcxx/test/std/utilities/memory/allocator.uses/allocator.uses.construction/uses_allocator_construction_args.pass.cpp
index ab3c039497dd955..fbdd2c00a21132f 100644
--- a/libcxx/test/std/utilities/memory/allocator.uses/allocator.uses.construction/uses_allocator_construction_args.pass.cpp
+++ b/libcxx/test/std/utilities/memory/allocator.uses/allocator.uses.construction/uses_allocator_construction_args.pass.cpp
@@ -121,6 +121,16 @@ constexpr void testOne() {
     assert(std::get<2>(std::get<1>(ret)) == 3);
     assert(std::get<0>(std::get<2>(ret)) == 4);
   }
+  {
+    using nestedPairType = std::pair<std::pmr::string, std::pair<std::pmr::string, std::pmr::string>>;
+    std::pmr::polymorphic_allocator<nestedPairType> alloc;
+    std::same_as<std::tuple<std::piecewise_construct_t,
+                            std::tuple<const std::pmr::polymorphic_allocator<nestedPairType>&>,
+                            std::tuple<std::piecewise_construct_t,
+                                       std::tuple<const std::pmr::polymorphic_allocator<nestedPairType>&>,
+                                       std::tuple<const std::pmr::polymorphic_allocator<nestedPairType>&> >>> auto s =
+        test_uses_allocator_construction_args<nestedPairType>(alloc);
+  }
 #if TEST_STD_VER >= 23
   {
     std::pair p{3, 4};

>From 802d88351200a8471a12e7697beada263cd9b1d6 Mon Sep 17 00:00:00 2001
From: Shivam Kunwar <shivam.kunwar at kdab.com>
Date: Fri, 22 Sep 2023 10:20:00 +0530
Subject: [PATCH 03/10] tests

---
 .../uses_allocator_construction_args.pass.cpp                   | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libcxx/test/std/utilities/memory/allocator.uses/allocator.uses.construction/uses_allocator_construction_args.pass.cpp b/libcxx/test/std/utilities/memory/allocator.uses/allocator.uses.construction/uses_allocator_construction_args.pass.cpp
index fbdd2c00a21132f..09a2ff40ea71115 100644
--- a/libcxx/test/std/utilities/memory/allocator.uses/allocator.uses.construction/uses_allocator_construction_args.pass.cpp
+++ b/libcxx/test/std/utilities/memory/allocator.uses/allocator.uses.construction/uses_allocator_construction_args.pass.cpp
@@ -128,7 +128,7 @@ constexpr void testOne() {
                             std::tuple<const std::pmr::polymorphic_allocator<nestedPairType>&>,
                             std::tuple<std::piecewise_construct_t,
                                        std::tuple<const std::pmr::polymorphic_allocator<nestedPairType>&>,
-                                       std::tuple<const std::pmr::polymorphic_allocator<nestedPairType>&> >>> auto s =
+                                       std::tuple<const std::pmr::polymorphic_allocator<nestedPairType>&> >>> auto ret =
         test_uses_allocator_construction_args<nestedPairType>(alloc);
   }
 #if TEST_STD_VER >= 23

>From 889eac47961bb8b9874ab15a77043477b6591cd1 Mon Sep 17 00:00:00 2001
From: Shivam Kunwar <shivam.kunwar at kdab.com>
Date: Fri, 22 Sep 2023 12:10:31 +0530
Subject: [PATCH 04/10] missing header

---
 .../uses_allocator_construction_args.pass.cpp                    | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libcxx/test/std/utilities/memory/allocator.uses/allocator.uses.construction/uses_allocator_construction_args.pass.cpp b/libcxx/test/std/utilities/memory/allocator.uses/allocator.uses.construction/uses_allocator_construction_args.pass.cpp
index 09a2ff40ea71115..3df4a37cb86ba77 100644
--- a/libcxx/test/std/utilities/memory/allocator.uses/allocator.uses.construction/uses_allocator_construction_args.pass.cpp
+++ b/libcxx/test/std/utilities/memory/allocator.uses/allocator.uses.construction/uses_allocator_construction_args.pass.cpp
@@ -19,6 +19,7 @@
 #include <ranges>
 #include <tuple>
 #include <utility>
+#include <memory_resource>
 
 #include "common.h"
 #include "test_allocator.h"

>From 770c21974106dce6aea178e612e21ec6116f9538 Mon Sep 17 00:00:00 2001
From: Shivam Kunwar <shivam.kunwar at kdab.com>
Date: Fri, 22 Sep 2023 12:55:11 +0530
Subject: [PATCH 05/10] update the test correctly

---
 .../uses_allocator_construction_args.pass.cpp      | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/libcxx/test/std/utilities/memory/allocator.uses/allocator.uses.construction/uses_allocator_construction_args.pass.cpp b/libcxx/test/std/utilities/memory/allocator.uses/allocator.uses.construction/uses_allocator_construction_args.pass.cpp
index 3df4a37cb86ba77..042664947fce309 100644
--- a/libcxx/test/std/utilities/memory/allocator.uses/allocator.uses.construction/uses_allocator_construction_args.pass.cpp
+++ b/libcxx/test/std/utilities/memory/allocator.uses/allocator.uses.construction/uses_allocator_construction_args.pass.cpp
@@ -19,7 +19,6 @@
 #include <ranges>
 #include <tuple>
 #include <utility>
-#include <memory_resource>
 
 #include "common.h"
 #include "test_allocator.h"
@@ -123,13 +122,14 @@ constexpr void testOne() {
     assert(std::get<0>(std::get<2>(ret)) == 4);
   }
   {
-    using nestedPairType = std::pair<std::pmr::string, std::pair<std::pmr::string, std::pmr::string>>;
-    std::pmr::polymorphic_allocator<nestedPairType> alloc;
-    std::same_as<std::tuple<std::piecewise_construct_t,
-                            std::tuple<const std::pmr::polymorphic_allocator<nestedPairType>&>,
+    using nestedPairType = std::pair<std::string, std::pair<std::string, std::string>>;
+    std::allocator<nestedPairType> alloc;
+
+    [[maybe_unused]] std::same_as<std::tuple<std::piecewise_construct_t,
+                            std::tuple<const std::allocator<nestedPairType>&>,
                             std::tuple<std::piecewise_construct_t,
-                                       std::tuple<const std::pmr::polymorphic_allocator<nestedPairType>&>,
-                                       std::tuple<const std::pmr::polymorphic_allocator<nestedPairType>&> >>> auto ret =
+                                       std::tuple<const std::allocator<nestedPairType>&>,
+                                       std::tuple<const std::allocator<nestedPairType>&> >>> auto ret =
         test_uses_allocator_construction_args<nestedPairType>(alloc);
   }
 #if TEST_STD_VER >= 23

>From d266c220166affbcac7a52dd2d60b6bd2e8b646a Mon Sep 17 00:00:00 2001
From: Shivam Kunwar <shivam.kunwar at kdab.com>
Date: Thu, 21 Sep 2023 22:52:42 +0530
Subject: [PATCH 06/10] forward declarations for
 __uses_allocator_construction_args

---
 .../allocator.uses/allocator.uses.construction/common.h       | 1 +
 .../uses_allocator_construction_args.pass.cpp                 | 4 +---
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/libcxx/test/std/utilities/memory/allocator.uses/allocator.uses.construction/common.h b/libcxx/test/std/utilities/memory/allocator.uses/allocator.uses.construction/common.h
index 48b0fa85a8c2386..29da933e633263d 100644
--- a/libcxx/test/std/utilities/memory/allocator.uses/allocator.uses.construction/common.h
+++ b/libcxx/test/std/utilities/memory/allocator.uses/allocator.uses.construction/common.h
@@ -9,6 +9,7 @@
 #include "test_allocator.h"
 
 using Alloc = test_allocator<int>;
+using nestedPairType = std::pair<std::string, std::pair<std::string, std::string>>;
 
 enum class RefType {
   LValue,
diff --git a/libcxx/test/std/utilities/memory/allocator.uses/allocator.uses.construction/uses_allocator_construction_args.pass.cpp b/libcxx/test/std/utilities/memory/allocator.uses/allocator.uses.construction/uses_allocator_construction_args.pass.cpp
index 042664947fce309..1807ad73cc9a76d 100644
--- a/libcxx/test/std/utilities/memory/allocator.uses/allocator.uses.construction/uses_allocator_construction_args.pass.cpp
+++ b/libcxx/test/std/utilities/memory/allocator.uses/allocator.uses.construction/uses_allocator_construction_args.pass.cpp
@@ -32,6 +32,7 @@ constexpr decltype(auto) test_uses_allocator_construction_args(Args&&... args) {
 template <template <class> class CV>
 constexpr void testOne() {
   Alloc a(12);
+  std::allocator<nestedPairType> alloc;
   {
     std::same_as<std::tuple<std::allocator_arg_t, const Alloc&>> auto ret =
         test_uses_allocator_construction_args<CV<UsesAllocArgT>>(a);
@@ -122,9 +123,6 @@ constexpr void testOne() {
     assert(std::get<0>(std::get<2>(ret)) == 4);
   }
   {
-    using nestedPairType = std::pair<std::string, std::pair<std::string, std::string>>;
-    std::allocator<nestedPairType> alloc;
-
     [[maybe_unused]] std::same_as<std::tuple<std::piecewise_construct_t,
                             std::tuple<const std::allocator<nestedPairType>&>,
                             std::tuple<std::piecewise_construct_t,

>From 654b1f5285c28f9af214947e1bddcf50d6a2a8e0 Mon Sep 17 00:00:00 2001
From: Shivam Kunwar <shivam.kunwar at kdab.com>
Date: Fri, 22 Sep 2023 22:24:16 +0530
Subject: [PATCH 07/10] update the test

---
 .../allocator.uses.construction/common.h           |  4 +++-
 .../uses_allocator_construction_args.pass.cpp      | 14 +++++++-------
 2 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/libcxx/test/std/utilities/memory/allocator.uses/allocator.uses.construction/common.h b/libcxx/test/std/utilities/memory/allocator.uses/allocator.uses.construction/common.h
index 29da933e633263d..852120adc3112c5 100644
--- a/libcxx/test/std/utilities/memory/allocator.uses/allocator.uses.construction/common.h
+++ b/libcxx/test/std/utilities/memory/allocator.uses/allocator.uses.construction/common.h
@@ -7,9 +7,11 @@
 //===----------------------------------------------------------------------===//
 
 #include "test_allocator.h"
+#include <memory_resource>
 
 using Alloc = test_allocator<int>;
-using nestedPairType = std::pair<std::string, std::pair<std::string, std::string>>;
+using nestedPairType = std::pair<std::pmr::string, std::pair<std::pmr::string, std::pmr::string>>;
+std::pmr::polymorphic_allocator<nestedPairType> nestedPairAlloc;
 
 enum class RefType {
   LValue,
diff --git a/libcxx/test/std/utilities/memory/allocator.uses/allocator.uses.construction/uses_allocator_construction_args.pass.cpp b/libcxx/test/std/utilities/memory/allocator.uses/allocator.uses.construction/uses_allocator_construction_args.pass.cpp
index 1807ad73cc9a76d..cb526a02cd9f223 100644
--- a/libcxx/test/std/utilities/memory/allocator.uses/allocator.uses.construction/uses_allocator_construction_args.pass.cpp
+++ b/libcxx/test/std/utilities/memory/allocator.uses/allocator.uses.construction/uses_allocator_construction_args.pass.cpp
@@ -32,7 +32,6 @@ constexpr decltype(auto) test_uses_allocator_construction_args(Args&&... args) {
 template <template <class> class CV>
 constexpr void testOne() {
   Alloc a(12);
-  std::allocator<nestedPairType> alloc;
   {
     std::same_as<std::tuple<std::allocator_arg_t, const Alloc&>> auto ret =
         test_uses_allocator_construction_args<CV<UsesAllocArgT>>(a);
@@ -123,12 +122,13 @@ constexpr void testOne() {
     assert(std::get<0>(std::get<2>(ret)) == 4);
   }
   {
-    [[maybe_unused]] std::same_as<std::tuple<std::piecewise_construct_t,
-                            std::tuple<const std::allocator<nestedPairType>&>,
-                            std::tuple<std::piecewise_construct_t,
-                                       std::tuple<const std::allocator<nestedPairType>&>,
-                                       std::tuple<const std::allocator<nestedPairType>&> >>> auto ret =
-        test_uses_allocator_construction_args<nestedPairType>(alloc);
+    [[maybe_unused]] std::same_as<
+        std::tuple<std::piecewise_construct_t,
+                   std::tuple<const std::pmr::polymorphic_allocator<nestedPairType>&>,
+                   std::tuple<std::piecewise_construct_t,
+                              std::tuple<const std::pmr::polymorphic_allocator<nestedPairType>&>,
+                              std::tuple<const std::pmr::polymorphic_allocator<nestedPairType>&> >>> auto ret =
+        test_uses_allocator_construction_args<nestedPairType>(nestedPairAlloc);
   }
 #if TEST_STD_VER >= 23
   {

>From 5cf580778f8bcecdc49b0e3bd9798fb18240104c Mon Sep 17 00:00:00 2001
From: Shivam <75530356+phyBrackets at users.noreply.github.com>
Date: Tue, 26 Sep 2023 05:53:31 +0530
Subject: [PATCH 08/10] fix test

---
 .../memory/allocator.uses/allocator.uses.construction/common.h   | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libcxx/test/std/utilities/memory/allocator.uses/allocator.uses.construction/common.h b/libcxx/test/std/utilities/memory/allocator.uses/allocator.uses.construction/common.h
index 852120adc3112c5..d6ee253e6779a60 100644
--- a/libcxx/test/std/utilities/memory/allocator.uses/allocator.uses.construction/common.h
+++ b/libcxx/test/std/utilities/memory/allocator.uses/allocator.uses.construction/common.h
@@ -8,6 +8,7 @@
 
 #include "test_allocator.h"
 #include <memory_resource>
+#include <string>
 
 using Alloc = test_allocator<int>;
 using nestedPairType = std::pair<std::pmr::string, std::pair<std::pmr::string, std::pmr::string>>;

>From 2d9c6b7e025102d19bdcbfee64d9e9d08d9f95a4 Mon Sep 17 00:00:00 2001
From: Shivam Kunwar <shivam.kunwar at kdab.com>
Date: Wed, 11 Oct 2023 00:39:57 +0530
Subject: [PATCH 09/10] Rebase and update the test

---
 .../allocator.uses.construction/common.h      |  4 ---
 .../uses_allocator_construction_args.pass.cpp | 28 ++++++++++++++-----
 2 files changed, 21 insertions(+), 11 deletions(-)

diff --git a/libcxx/test/std/utilities/memory/allocator.uses/allocator.uses.construction/common.h b/libcxx/test/std/utilities/memory/allocator.uses/allocator.uses.construction/common.h
index d6ee253e6779a60..48b0fa85a8c2386 100644
--- a/libcxx/test/std/utilities/memory/allocator.uses/allocator.uses.construction/common.h
+++ b/libcxx/test/std/utilities/memory/allocator.uses/allocator.uses.construction/common.h
@@ -7,12 +7,8 @@
 //===----------------------------------------------------------------------===//
 
 #include "test_allocator.h"
-#include <memory_resource>
-#include <string>
 
 using Alloc = test_allocator<int>;
-using nestedPairType = std::pair<std::pmr::string, std::pair<std::pmr::string, std::pmr::string>>;
-std::pmr::polymorphic_allocator<nestedPairType> nestedPairAlloc;
 
 enum class RefType {
   LValue,
diff --git a/libcxx/test/std/utilities/memory/allocator.uses/allocator.uses.construction/uses_allocator_construction_args.pass.cpp b/libcxx/test/std/utilities/memory/allocator.uses/allocator.uses.construction/uses_allocator_construction_args.pass.cpp
index cb526a02cd9f223..849113141ebec9e 100644
--- a/libcxx/test/std/utilities/memory/allocator.uses/allocator.uses.construction/uses_allocator_construction_args.pass.cpp
+++ b/libcxx/test/std/utilities/memory/allocator.uses/allocator.uses.construction/uses_allocator_construction_args.pass.cpp
@@ -122,13 +122,27 @@ constexpr void testOne() {
     assert(std::get<0>(std::get<2>(ret)) == 4);
   }
   {
-    [[maybe_unused]] std::same_as<
-        std::tuple<std::piecewise_construct_t,
-                   std::tuple<const std::pmr::polymorphic_allocator<nestedPairType>&>,
-                   std::tuple<std::piecewise_construct_t,
-                              std::tuple<const std::pmr::polymorphic_allocator<nestedPairType>&>,
-                              std::tuple<const std::pmr::polymorphic_allocator<nestedPairType>&> >>> auto ret =
-        test_uses_allocator_construction_args<nestedPairType>(nestedPairAlloc);
+    // See https://github.com/llvm/llvm-project/issues/66714
+    {
+      using NestedPairType = std::pair<int, std::pair<int, UsesAllocArgT>>;
+      std::same_as<std::tuple<std::piecewise_construct_t,
+                              std::tuple<>,
+                              std::tuple<std::piecewise_construct_t,
+                                         std::tuple<>,
+                                         std::tuple<std::allocator_arg_t, const Alloc&>>>> auto ret =
+          test_uses_allocator_construction_args<NestedPairType>(a);
+          (void)ret;
+    }
+    {
+      using NestedPairType = std::pair<int, std::pair<UsesAllocArgT, int>>;
+      std::same_as<std::tuple<std::piecewise_construct_t,
+                              std::tuple<>,
+                              std::tuple<std::piecewise_construct_t,
+                                         std::tuple<std::allocator_arg_t, const Alloc&>,
+                                         std::tuple<>>>> auto ret =
+        test_uses_allocator_construction_args<NestedPairType>(a);
+        (void)ret;
+    }
   }
 #if TEST_STD_VER >= 23
   {

>From b14cd768fc081d0339da922d4c2ee111bbfb6c72 Mon Sep 17 00:00:00 2001
From: Shivam Kunwar <shivam.kunwar at kdab.com>
Date: Mon, 16 Oct 2023 10:55:52 +0530
Subject: [PATCH 10/10] added the tests for forward declarations

---
 .../uses_allocator_construction_args.pass.cpp | 58 ++++++++++++++++---
 1 file changed, 50 insertions(+), 8 deletions(-)

diff --git a/libcxx/test/std/utilities/memory/allocator.uses/allocator.uses.construction/uses_allocator_construction_args.pass.cpp b/libcxx/test/std/utilities/memory/allocator.uses/allocator.uses.construction/uses_allocator_construction_args.pass.cpp
index 849113141ebec9e..6db5123e4850faf 100644
--- a/libcxx/test/std/utilities/memory/allocator.uses/allocator.uses.construction/uses_allocator_construction_args.pass.cpp
+++ b/libcxx/test/std/utilities/memory/allocator.uses/allocator.uses.construction/uses_allocator_construction_args.pass.cpp
@@ -122,27 +122,69 @@ constexpr void testOne() {
     assert(std::get<0>(std::get<2>(ret)) == 4);
   }
   {
-    // See https://github.com/llvm/llvm-project/issues/66714
+     // Tests for ensuring forward declarations of uses_allocator_construction_args
     {
       using NestedPairType = std::pair<int, std::pair<int, UsesAllocArgT>>;
       std::same_as<std::tuple<std::piecewise_construct_t,
+                   std::tuple<>,
+                   std::tuple<std::piecewise_construct_t,
                               std::tuple<>,
-                              std::tuple<std::piecewise_construct_t,
-                                         std::tuple<>,
-                                         std::tuple<std::allocator_arg_t, const Alloc&>>>> auto ret =
+                              std::tuple<std::allocator_arg_t, const Alloc&>>>> auto ret =
           test_uses_allocator_construction_args<NestedPairType>(a);
           (void)ret;
     }
     {
       using NestedPairType = std::pair<int, std::pair<UsesAllocArgT, int>>;
       std::same_as<std::tuple<std::piecewise_construct_t,
-                              std::tuple<>,
-                              std::tuple<std::piecewise_construct_t,
-                                         std::tuple<std::allocator_arg_t, const Alloc&>,
-                                         std::tuple<>>>> auto ret =
+                   std::tuple<>,
+                   std::tuple<std::piecewise_construct_t,
+                              std::tuple<std::allocator_arg_t, const Alloc&>,
+                              std::tuple<>>>> auto ret =
         test_uses_allocator_construction_args<NestedPairType>(a);
         (void)ret;
     }
+    {
+      using PairType = std::pair<int, int>;
+      int up = 1;
+      int vp = 2;
+    
+      std::same_as<std::tuple<std::piecewise_construct_t,
+                   std::tuple<int&&>,
+                   std::tuple<int&&>>> auto ret = 
+        test_uses_allocator_construction_args<PairType>(a, std::move(up), std::move(vp));
+        (void)ret;
+    }
+    {
+      using PairType = std::pair<int, int>;
+      PairType p(1, 2);
+    
+      std::same_as<std::tuple<std::piecewise_construct_t,
+                   std::tuple<int&>,
+                   std::tuple<int&>>> auto ret =
+        test_uses_allocator_construction_args<PairType>(a, p);
+        (void)ret;
+    }
+    {
+      using PairType = std::pair<int, int>;
+      PairType p(1, 2);
+    
+      std::same_as<std::tuple<std::piecewise_construct_t,
+                   std::tuple<int&&>,
+                   std::tuple<int&&>>> auto ret =
+        test_uses_allocator_construction_args<PairType>(a, std::move(p));
+        (void)ret;
+    }
+    {
+      using PairType = std::pair<int, int>;
+      PairType p(1, 2);
+    
+      std::same_as<std::tuple<std::piecewise_construct_t,
+                   std::tuple<const int&&>,
+                   std::tuple<const int&&>>> auto ret =
+        test_uses_allocator_construction_args<PairType>(a, std::move(p));
+        (void)ret;
+    }
+  }
   }
 #if TEST_STD_VER >= 23
   {



More information about the libcxx-commits mailing list