From patchwork Sun Jul 11 09:16:39 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 58519 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 9AED5B6EDD for ; Sun, 11 Jul 2010 19:16:54 +1000 (EST) Received: (qmail 4813 invoked by alias); 11 Jul 2010 09:16:49 -0000 Received: (qmail 4795 invoked by uid 22791); 11 Jul 2010 09:16:48 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE X-Spam-Check-By: sourceware.org Received: from vsmtp2.tin.it (HELO vsmtp2.tin.it) (212.216.176.222) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 11 Jul 2010 09:16:42 +0000 Received: from [192.168.0.4] (79.53.234.114) by vsmtp2.tin.it (8.0.022) id 49F5BE4223BA1CFE; Sun, 11 Jul 2010 11:16:39 +0200 Message-ID: <4C398BF7.30903@oracle.com> Date: Sun, 11 Jul 2010 11:16:39 +0200 From: Paolo Carlini User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.10) Gecko/20100520 SUSE/3.0.5 Thunderbird/3.0.5 MIME-Version: 1.0 To: "gcc-patches@gcc.gnu.org" CC: libstdc++ Subject: [v3] Change is_convertible to use SFINAE X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Hi, this changes is_convertible to use SFINAE, which then fails *only* because of access control (I'll add additional testcases when a couple of front-end issues are resolved). Tested x86_64-linux, committed. Paolo. //////////////////// 2010-07-11 Paolo Carlini * include/std/type_traits (is_convertible): Use SFINAE. * testsuite/20_util/make_signed/requirements/typedefs_neg.cc: Adjust dg-error line numbers. * testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc: Likewise. * testsuite/20_util/declval/requirements/1_neg.cc: Likewise. Index: include/std/type_traits =================================================================== --- include/std/type_traits (revision 162054) +++ include/std/type_traits (working copy) @@ -307,21 +307,27 @@ { }; template::value || is_void<_To>::value - || is_function<_To>::value || is_array<_To>::value)> + bool = (is_void<_From>::value || is_function<_To>::value + || is_array<_To>::value)> struct __is_convertible_helper - { static const bool __value = (is_void<_From>::value - && is_void<_To>::value); }; + { static const bool __value = is_void<_To>::value; }; template class __is_convertible_helper<_From, _To, false> : public __sfinae_types { - static __one __test(_To); - static __two __test(...); + template + static void __test_aux(_To1); + template + static decltype(__test_aux<_To1>(std::declval<_From1>()), __one()) + __test(int); + + template + static __two __test(...); + public: - static const bool __value = sizeof(__test(declval<_From>())) == 1; + static const bool __value = sizeof(__test<_From, _To>(0)) == 1; }; /// is_convertible Index: testsuite/20_util/make_signed/requirements/typedefs_neg.cc =================================================================== --- testsuite/20_util/make_signed/requirements/typedefs_neg.cc (revision 162054) +++ testsuite/20_util/make_signed/requirements/typedefs_neg.cc (working copy) @@ -48,5 +48,5 @@ // { dg-error "instantiated from here" "" { target *-*-* } 40 } // { dg-error "instantiated from here" "" { target *-*-* } 42 } -// { dg-error "invalid use of incomplete type" "" { target *-*-* } 639 } -// { dg-error "declaration of" "" { target *-*-* } 603 } +// { dg-error "invalid use of incomplete type" "" { target *-*-* } 645 } +// { dg-error "declaration of" "" { target *-*-* } 609 } Index: testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc =================================================================== --- testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc (revision 162054) +++ testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc (working copy) @@ -48,5 +48,5 @@ // { dg-error "instantiated from here" "" { target *-*-* } 40 } // { dg-error "instantiated from here" "" { target *-*-* } 42 } -// { dg-error "invalid use of incomplete type" "" { target *-*-* } 562 } -// { dg-error "declaration of" "" { target *-*-* } 526 } +// { dg-error "invalid use of incomplete type" "" { target *-*-* } 568 } +// { dg-error "declaration of" "" { target *-*-* } 532 } Index: testsuite/20_util/declval/requirements/1_neg.cc =================================================================== --- testsuite/20_util/declval/requirements/1_neg.cc (revision 162054) +++ testsuite/20_util/declval/requirements/1_neg.cc (working copy) @@ -19,7 +19,7 @@ // with this library; see the file COPYING3. If not see // . -// { dg-error "static assertion failed" "" { target *-*-* } 676 } +// { dg-error "static assertion failed" "" { target *-*-* } 682 } #include