Support allocators in tuples of zero size.
authorVille Voutilainen <ville.voutilainen@gmail.com>
Mon, 6 Jun 2016 16:28:59 +0000 (19:28 +0300)
committerVille Voutilainen <ville@gcc.gnu.org>
Mon, 6 Jun 2016 16:28:59 +0000 (19:28 +0300)
* include/std/tuple (tuple<>::tuple(),
tuple<>::tuple(allocator_arg_t, const _Alloc&),
tuple<>::tuple(allocator_arg_t, const _Alloc&, const tuple&)): New.
* testsuite/20_util/tuple/cons/allocators.cc: Adjust.

From-SVN: r237143

libstdc++-v3/ChangeLog
libstdc++-v3/include/std/tuple
libstdc++-v3/testsuite/20_util/tuple/cons/allocators.cc

index b938ea2bb6d2cdbfed4a6f0f3f8151933b77d4e7..f550c35eb15fd50ea04c83820b3ddd5d9b22ffe2 100644 (file)
@@ -1,3 +1,11 @@
+2016-06-06  Ville Voutilainen  <ville.voutilainen@gmail.com>
+
+       Support allocators in tuples of zero size.
+       * include/std/tuple (tuple<>::tuple(),
+       tuple<>::tuple(allocator_arg_t, const _Alloc&),
+       tuple<>::tuple(allocator_arg_t, const _Alloc&, const tuple&)): New.
+       * testsuite/20_util/tuple/cons/allocators.cc: Adjust.
+
 2016-06-06  Jonathan Wakely  <jwakely@redhat.com>
 
        PR libstdc++/71320
index 17c820490300a0c180e90fa4f31d2eb6ed6b2176..e64f6bfc5f571776d8a57fc6da3138951234ff62 100644 (file)
@@ -876,6 +876,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     {
     public:
       void swap(tuple&) noexcept { /* no-op */ }
+      // We need the default since we're going to define no-op
+      // allocator constructors.
+      tuple() = default;
+      // No-op allocator constructors.
+      template<typename _Alloc>
+       tuple(allocator_arg_t, const _Alloc&) { }
+      template<typename _Alloc>
+       tuple(allocator_arg_t, const _Alloc&, const tuple&) { }
     };
 
   /// Partial specialization, 2-element tuple.
index 052b79fcf83d7fb1482edb5d099bee82dfdf32d7..bc45780cb9865c55c40f31a8d6e7a588824a38e5 100644 (file)
@@ -162,8 +162,30 @@ void test01()
 
 }
 
+void test02()
+{
+  bool test __attribute__((unused)) = true;
+  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();
+}
+
 int main()
 {
   test01();
+  test02();
   return 0;
 }