]> git.ipfire.org Git - thirdparty/gcc.git/blobdiff - libstdc++-v3/testsuite/20_util/tuple/cons/allocators.cc
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 20_util / tuple / cons / allocators.cc
index 9b1c6a7f34effbf1d68ad1bd382aa747c757eed4..9a5c745cb26646c66d60a0e03b20383a6ca59f9a 100644 (file)
@@ -1,6 +1,8 @@
-// { dg-options "-std=gnu++0x" }
+// { dg-do run { target c++11 } }
+// FIXME [!HOSTED]: avoidable std::allocator usage
+// { dg-require-effective-target hosted }
 
-// Copyright (C) 2011-2014 Free Software Foundation, Inc.
+// Copyright (C) 2011-2024 Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
 // software; you can redistribute it and/or modify it under the
@@ -102,7 +104,6 @@ struct UsesWithoutTag
 
 void test01()
 {
-  bool test __attribute__((unused)) = true;
   using std::allocator_arg;
   using std::tuple;
   using std::make_tuple;
@@ -162,8 +163,58 @@ void test01()
 
 }
 
+void test02()
+{
+  using std::allocator_arg;
+  using std::tuple;
+  using std::make_tuple;
+
+  typedef tuple<> test_type;
+
+  MyAlloc a;
+
+  // default construction
+  test_type t1(allocator_arg, a);
+  // copy construction
+  test_type t2(allocator_arg, a, t1);
+  // move construction
+  test_type t3(allocator_arg, a, std::move(t1));
+  // make_tuple
+  test_type empty = make_tuple();
+}
+
+void test03()
+{
+  struct dr2586
+  {
+    using allocator_type = std::allocator<int>;
+    dr2586() { }
+    dr2586(std::allocator_arg_t, allocator_type&&) { }
+    dr2586(const allocator_type&) : expected(true) { }
+    bool expected = false;
+  };
+
+  const dr2586::allocator_type a;
+  std::tuple<dr2586> t{std::allocator_arg, a};
+  VERIFY( std::get<0>(t).expected );
+}
+
+void test04()
+{
+  struct X {
+    X(std::allocator_arg_t) { }
+  };
+
+  // The element types are not default constructible, so the allocator-extended
+  // default constructor should not participate in overload resolution.
+  std::tuple<X, void(&)()> t(std::allocator_arg, *+[]{});
+}
+
 int main()
 {
   test01();
+  test02();
+  test03();
+  test04();
   return 0;
 }