On 11/21/2011 03:05 AM, Jason Merrill wrote:
On 11/20/2011 08:02 PM, Paolo Carlini wrote:
.. also, I was under the impression that c++/48322 was the only reason
we couldn't write something very simple, thus no __all_convertible, ie,
something using directly:

enable_if<__and_<is_convertible<_UElements, _Elements>...>::value>::type

Yep, you can do that now.

That would be a great improvement, even if we need to SFINAE separately
for equal sizeofs.

You don't need to, you can just drop the sizeof check now.
Ah great. Thus I tested and committed the below.

Thanks again for the explanations to both of you,
Paolo.

///////////////////
2011-11-21  Paolo Carlini  <paolo.carl...@oracle.com>

        * include/std/tuple (__conv_types, __one_by_one_convertible,
        __all_convertible): Remove.
        (tuple<>::tuple(_UElements&&...),
        tuple<>::tuple(const tuple<_UElements...>&),
        tuple<>::tuple(tuple<_UElements...>&&)): Remove wa for c++/48322.
        * testsuite/20_util/uses_allocator/cons_neg.cc: Adjust dg-error
        line number.
Index: include/std/tuple
===================================================================
--- include/std/tuple   (revision 181554)
+++ include/std/tuple   (working copy)
@@ -69,35 +69,6 @@
     struct __add_r_ref<_Tp&>
     { typedef _Tp& type; };
 
-  // To work around c++/49225 aka c++/48322.
-  template<typename...>
-    struct __conv_types { };
-
-  template<typename _Tuple1, typename _Tuple2>
-    struct __one_by_one_convertible
-    : public false_type { };
-
-  template<typename _Tp, typename _Up>
-    struct __one_by_one_convertible<__conv_types<_Tp>, __conv_types<_Up>>
-    : public is_convertible<_Tp, _Up>::type { };
-
-  template<typename _T1, typename... _TR, typename _U1, typename... _UR>
-    struct __one_by_one_convertible<__conv_types<_T1, _TR...>,
-                                    __conv_types<_U1, _UR...>>
-    : public __and_<is_convertible<_T1, _U1>,
-                    __one_by_one_convertible<__conv_types<_TR...>,
-                                             __conv_types<_UR...>>>::type
-    { };
-
-  template<typename _Tuple1, typename _Tuple2>
-    struct __all_convertible;
-
-  template<typename... _TTypes, typename... _UTypes>
-    struct __all_convertible<__conv_types<_TTypes...>,
-                             __conv_types<_UTypes...>>
-    : public __one_by_one_convertible<__conv_types<_TTypes...>,
-                                      __conv_types<_UTypes...>>::type { };
-
   template<std::size_t _Idx, typename _Head, bool _IsEmpty>
     struct _Head_base;
 
@@ -407,13 +378,9 @@
       constexpr tuple(const _Elements&... __elements)
       : _Inherited(__elements...) { }
 
-      template<typename... _UElements,
-              typename = typename enable_if<sizeof...(_UElements)
-                                            == sizeof...(_Elements)>::type,
-              typename = typename
-                enable_if<__all_convertible<__conv_types<_UElements...>,
-                                            __conv_types<_Elements...> >::value
-                          >::type>
+      template<typename... _UElements, typename = typename
+        enable_if<__and_<is_convertible<_UElements,
+                                       _Elements>...>::value>::type>
        explicit
         constexpr tuple(_UElements&&... __elements)
        : _Inherited(std::forward<_UElements>(__elements)...) { }
@@ -423,21 +390,15 @@
       constexpr tuple(tuple&&) = default; 
 
       template<typename... _UElements, typename = typename
-       enable_if<__and_<integral_constant<bool, sizeof...(_UElements)
-                                          == sizeof...(_Elements)>,
-                        __all_convertible<__conv_types<const _UElements&...>,
-                                          __conv_types<_Elements...>>
-                         >::value>::type>
+        enable_if<__and_<is_convertible<const _UElements&,
+                                       _Elements>...>::value>::type>
         constexpr tuple(const tuple<_UElements...>& __in)
         : _Inherited(static_cast<const _Tuple_impl<0, _UElements...>&>(__in))
         { }
 
       template<typename... _UElements, typename = typename
-       enable_if<__and_<integral_constant<bool, sizeof...(_UElements)
-                                          == sizeof...(_Elements)>,
-                        __all_convertible<__conv_types<_UElements...>,
-                                          __conv_types<_Elements...>>
-                        >::value>::type>
+        enable_if<__and_<is_convertible<_UElements,
+                                       _Elements>...>::value>::type>
         constexpr tuple(tuple<_UElements...>&& __in)
         : _Inherited(static_cast<_Tuple_impl<0, _UElements...>&&>(__in)) { }
 
Index: testsuite/20_util/uses_allocator/cons_neg.cc
===================================================================
--- testsuite/20_util/uses_allocator/cons_neg.cc        (revision 181554)
+++ testsuite/20_util/uses_allocator/cons_neg.cc        (working copy)
@@ -44,4 +44,4 @@
 
   tuple<Type> t(allocator_arg, a, 1);
 }
-// { dg-error "no matching function" "" { target *-*-* } 141 }
+// { dg-error "no matching function" "" { target *-*-* } 112 }

Reply via email to