Patchwork [v3] implement allocator-extended constructors in <tuple>

login
register
mail settings
Submitter Jonathan Wakely
Date May 30, 2011, 11:54 p.m.
Message ID <BANLkTim05MriiBryvSrmnzR0ZAwpTqFx6Q@mail.gmail.com>
Download mbox | patch
Permalink /patch/97959/
State New
Headers show

Comments

Jonathan Wakely - May 30, 2011, 11:54 p.m.
2011-05-31  Jonathan Wakely  <jwakely.gcc@gmail.com>

	* include/std/tuple: Restore is_convertible constraint.
	* testsuite/20_util/tuple/cons/allocate_noncopyable.cc: Remove.

Paolo explained some details about the constraints on the tuple
constructor and I'm reverting the part of change from is_convertible
to is_constructible

Patch

Index: include/std/tuple
===================================================================
--- include/std/tuple	(revision 174456)
+++ include/std/tuple	(working copy)
@@ -629,7 +629,7 @@ 
       : _Inherited(__a1) { }
 
       template<typename _U1, typename = typename
-	       std::enable_if<std::is_constructible<_T1, _U1&&>::value>::type>
+	       std::enable_if<std::is_convertible<_U1, _T1>::value>::type>
         explicit
         tuple(_U1&& __a1)
 	: _Inherited(std::forward<_U1>(__a1)) { }
Index: testsuite/20_util/tuple/cons/allocate_noncopyable.cc
===================================================================
--- testsuite/20_util/tuple/cons/allocate_noncopyable.cc	(revision 174456)
+++ testsuite/20_util/tuple/cons/allocate_noncopyable.cc	(working copy)
@@ -1,73 +0,0 @@ 
-// { dg-options "-std=gnu++0x" }
-// { dg-do compile }
-
-// Copyright (C) 2011 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
-// terms of the GNU General Public License as published by the
-// Free Software Foundation; either version 3, or (at your option)
-// any later version.
-
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-// 20.4.2.1 [tuple.cnstr] Allocator-extended constructors
-
-#include <memory>
-#include <tuple>
-
-struct MyAlloc { };
-
-struct Tag0 { };
-struct Tag1 { };
-struct Tag2 { };
-
-// A non-copyable and non-movable type
-struct Type
-{
-  typedef MyAlloc allocator_type;
-
-  explicit Type(Tag0) { }
-  Type(std::allocator_arg_t, MyAlloc, Tag1) { }
-  Type(Tag2, MyAlloc) { }
-
-  Type(const Type&) = delete;
-  Type(Type&&) = delete;
-  Type& operator=(const Type&) = delete;
-  Type& operator=(Type&&) = delete;
-};
-
-void test01()
-{
-  using std::allocator_arg;
-  using std::tuple;
-
-  MyAlloc a;
-  Tag0 tag0;
-  Tag1 tag1;
-  Tag2 tag2;
-
-  // N.B. cannot use Tag0 with uses-allocator construction, because
-  // uses_allocator<Type, MyAlloc> is true but no suitable cosntructor
-  tuple<Type>		  t1(tag0);
-
-  tuple<Type> 		  t2(allocator_arg, a, tag1);
-  tuple<Type> 		  t3(allocator_arg, a, tag2);
-
-  tuple<Type, Type> 	  t4(allocator_arg, a, tag1, tag2);
-
-  tuple<Type, Type, Type> t5(allocator_arg, a, tag2, tag1, tag2);
-}
-
-int main()
-{
-  test01();
-  return 0;
-}