@@ -196,7 +196,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
}
template<typename _Tp, typename _Alloc, typename... _Args>
- inline _Tp
+ constexpr _Tp
make_obj_using_allocator(const _Alloc& __a, _Args&&... __args)
{
return std::make_from_tuple<_Tp>(
@@ -205,7 +205,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
}
template<typename _Tp, typename _Alloc, typename... _Args>
- inline _Tp*
+ constexpr _Tp*
uninitialized_construct_using_allocator(_Tp* __p, const _Alloc& __a,
_Args&&... __args)
{
@@ -142,7 +142,7 @@ test01()
VERIFY( c2.alloc_id == 1 );
}
-void
+void
test02()
{
decltype(auto) b
@@ -389,6 +389,34 @@ test08()
std::make_obj_using_allocator<X>(a);
}
+constexpr bool
+test_pr104542()
+{
+ // PR libstdc++/104542 - missing constexpr
+ std::allocator<void> a;
+ int i = std::make_obj_using_allocator<int>(a, 1);
+
+ struct X {
+ using allocator_type = std::allocator<long>;
+ constexpr X(std::allocator_arg_t, std::allocator<int>, int i) : i(i+1) { }
+ int i;
+ };
+
+ X x = std::make_obj_using_allocator<X>(a, i);
+
+ struct Y {
+ using allocator_type = std::allocator<char>;
+ constexpr Y(X x, std::allocator<int>) : i(x.i+1) { }
+ int i;
+ };
+
+ Y y = std::make_obj_using_allocator<Y>(a, x);
+
+ return y.i == 3;
+}
+
+static_assert( test_pr104542() );
+
int
main()
{
new file mode 100644
@@ -0,0 +1,17 @@
+// { dg-options "-std=gnu++20" }
+// { dg-do compile { target c++20 } }
+
+#include <memory>
+
+constexpr bool
+test_pr104542()
+{
+ // PR libstdc++/104542 - missing constexpr
+ std::allocator<int> a;
+ int* p = a.allocate(1);
+ int i = *std::uninitialized_construct_using_allocator<int>(p, a, 999);
+ a.deallocate(p, 1);
+ return i == 999;
+}
+
+static_assert( test_pr104542() );