From patchwork Thu Sep 1 19:33:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 907 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:ecc5:0:0:0:0:0 with SMTP id s5csp398773wro; Thu, 1 Sep 2022 12:35:55 -0700 (PDT) X-Google-Smtp-Source: AA6agR4VYBEqapdnaSQMAQigGzOGCpNSmIjB757wPeKcw9U9q1seZCvbt/iqipwyYxaSMmIoivtq X-Received: by 2002:a17:907:2702:b0:741:5881:1054 with SMTP id w2-20020a170907270200b0074158811054mr16973349ejk.411.1662060955797; Thu, 01 Sep 2022 12:35:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662060955; cv=none; d=google.com; s=arc-20160816; b=sm3tzuPew2PV0jmIjLIqDtavXuomAact/DElvg6qHishEKm954soce/dj8Wo2Cg8sO T5bybe4JpPEBkPWevP/MT2S9nMNJDaNh12uMQ9LT4ys8O0ODk6F4iuTK2JefgFaexOY+ n+N+gwHeXrweNJh87qegv7WhCK3ZPTqeVj7ERPtNm1DN8SW6wMu2cULXnRoOKbi2JMHy ad2gS2CCdnyYAsb22KOkgAaV7f9EqXP55Vbqd/kj65n5YYvgZoxf953WTFYkYqqCC+UT 3gz0tL6nYLnusRT9NYsFDPhjk8m/SFKjjoL2dRRj7vyTw7txWrlk37b7mai4I3zJE4Y/ uZkQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:message-id:date:subject:to :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=szsSfiIJAX2vax42oUxvdEgSHuS4fsS0WCk5+tzBn7M=; b=f9CsTloSJ/eFtAv4bJ/hiF988I2QQHbKXvEbfI8pJXCNeVkrhSkS9P8PeNrWhm0ws3 EA4C5aTvG7uKwEzeMc2nZGHRVAqTZCvYPbNUpm6BkWd1xc4uuw6ZCUJm3DVWQWzcF2JG fNf3VlC5hMu1rW/f9e7V5sD3F0pc6NmpWJvrzZmNdNnQhnK3pPvKczi2vVJmtcHOq4FI dkJuEPSm6w2GgRPvAjPyrbGrYMUhq/XW2499BsyDFxoet/OlAYVNXGdDa/txS+WJnRVY 526nr4uyNu/L1pxvK9KBfviE/QcOD1FrwJ4QxvRJ1ZTACVkdxXcF5oiSl4oDq1oj1q+c djgw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=RNgJTY2V; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id f22-20020a17090631d600b0073dd946b66asi71669ejf.444.2022.09.01.12.35.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Sep 2022 12:35:55 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=RNgJTY2V; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D9C24382DA65 for ; Thu, 1 Sep 2022 19:34:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D9C24382DA65 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1662060882; bh=szsSfiIJAX2vax42oUxvdEgSHuS4fsS0WCk5+tzBn7M=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=RNgJTY2VUFNNecgYISsTUZ7Q4wtfdvxE4IiXt0bIZE3CnpnyWfGpdNCdO5Bpl/Fpi jDw+MQW80FpYktELSy+DRWIcm9Vnzd3M4BTa02YxmnRkYmfUdkGt+NsnqUxBh11vAL OQZAtt/R72xlKF6Z6r77BncHwZSFhNVrmj6rwJ60= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 985DD3857364 for ; Thu, 1 Sep 2022 19:33:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 985DD3857364 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-197-xkmLvdmWOEqeBgD_GGHX1w-1; Thu, 01 Sep 2022 15:33:52 -0400 X-MC-Unique: xkmLvdmWOEqeBgD_GGHX1w-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 84FA63815D35; Thu, 1 Sep 2022 19:33:52 +0000 (UTC) Received: from localhost (unknown [10.33.36.187]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2FC452026D4C; Thu, 1 Sep 2022 19:33:52 +0000 (UTC) To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [committed] libstdc++: Optimize is_constructible traits Date: Thu, 1 Sep 2022 20:33:51 +0100 Message-Id: <20220901193351.352611-1-jwakely@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.8 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Jonathan Wakely via Gcc-patches From: Jonathan Wakely Reply-To: Jonathan Wakely Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1742797228667993682?= X-GMAIL-MSGID: =?utf-8?q?1742797228667993682?= Tested powerpc64le-linux, pushed to trunk. -- >8 -- We can replace some class template helpers with alias templates, which are cheaper to instantiate. For example, replace the __is_copy_constructible_impl class template with an alias template that uses just evaluates the __is_constructible built-in, using add_lvalue_reference to get the argument type in a way that works for non-referenceable types. For a given specialization of is_copy_constructible this results in the same number of class templates being instantiated (for the common case of non-void, non-function types), but the add_lvalue_reference instantiations are not specific to the is_copy_constructible specialization and so can be reused by other traits. Previously __is_copy_constructible_impl was a distinct class template and its specializations were never used for anything except is_copy_constructible. With the new definitions of these traits that don't depend on helper classes, it becomes more practical to optimize the is_xxx_constructible_v variable templates to avoid instantiations. Previously doing so would have meant two entirely separate implementation strategies for these traits. libstdc++-v3/ChangeLog: * include/std/type_traits (__is_constructible_impl): Replace class template with alias template. (is_default_constructible, is_nothrow_constructible) (is_nothrow_constructible): Simplify base-specifier. (__is_copy_constructible_impl, __is_move_constructible_impl) (__is_nothrow_copy_constructible_impl) (__is_nothrow_move_constructible_impl): Remove class templates. (is_copy_constructible, is_move_constructible) (is_nothrow_constructible, is_nothrow_default_constructible) (is_nothrow_copy_constructible, is_nothrow_move_constructible): Adjust base-specifiers to use __is_constructible_impl. (__is_copy_assignable_impl, __is_move_assignable_impl) (__is_nt_copy_assignable_impl, __is_nt_move_assignable_impl): Remove class templates. (__is_assignable_impl): New alias template. (is_assignable, is_copy_assignable, is_move_assignable): Adjust base-specifiers to use new alias template. (is_nothrow_copy_assignable, is_nothrow_move_assignable): Adjust base-specifiers to use existing alias template. (__is_trivially_constructible_impl): New alias template. (is_trivially_constructible, is_trivially_default_constructible) (is_trivially_copy_constructible) (is_trivially_move_constructible): Adjust base-specifiers to use new alias template. (__is_trivially_assignable_impl): New alias template. (is_trivially_assignable, is_trivially_copy_assignable) (is_trivially_move_assignable): Adjust base-specifier to use new alias template. (__add_lval_ref_t, __add_rval_ref_t): New alias templates. (add_lvalue_reference, add_rvalue_reference): Use new alias templates. --- libstdc++-v3/include/std/type_traits | 249 +++++++-------------------- 1 file changed, 62 insertions(+), 187 deletions(-) diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits index 639c351df8a..3041ac3c941 100644 --- a/libstdc++-v3/include/std/type_traits +++ b/libstdc++-v3/include/std/type_traits @@ -1001,9 +1001,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION /// @cond undocumented template - struct __is_constructible_impl - : public __bool_constant<__is_constructible(_Tp, _Args...)> - { }; + using __is_constructible_impl + = __bool_constant<__is_constructible(_Tp, _Args...)>; /// @endcond /// is_constructible @@ -1018,7 +1017,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION /// is_default_constructible template struct is_default_constructible - : public __is_constructible_impl<_Tp>::type + : public __is_constructible_impl<_Tp> { static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), "template argument must be a complete class or an unbounded array"); @@ -1026,22 +1025,21 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION /// @cond undocumented template::value> - struct __is_copy_constructible_impl; + struct __add_lvalue_reference_helper + { using type = _Tp; }; template - struct __is_copy_constructible_impl<_Tp, false> - : public false_type { }; + struct __add_lvalue_reference_helper<_Tp, true> + { using type = _Tp&; }; template - struct __is_copy_constructible_impl<_Tp, true> - : public __is_constructible_impl<_Tp, const _Tp&> - { }; + using __add_lval_ref_t = typename __add_lvalue_reference_helper<_Tp>::type; /// @endcond /// is_copy_constructible template struct is_copy_constructible - : public __is_copy_constructible_impl<_Tp> + : public __is_constructible_impl<_Tp, __add_lval_ref_t> { static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), "template argument must be a complete class or an unbounded array"); @@ -1049,22 +1047,21 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION /// @cond undocumented template::value> - struct __is_move_constructible_impl; + struct __add_rvalue_reference_helper + { using type = _Tp; }; template - struct __is_move_constructible_impl<_Tp, false> - : public false_type { }; + struct __add_rvalue_reference_helper<_Tp, true> + { using type = _Tp&&; }; template - struct __is_move_constructible_impl<_Tp, true> - : public __is_constructible_impl<_Tp, _Tp&&> - { }; + using __add_rval_ref_t = typename __add_rvalue_reference_helper<_Tp>::type; /// @endcond /// is_move_constructible template struct is_move_constructible - : public __is_move_constructible_impl<_Tp> + : public __is_constructible_impl<_Tp, __add_rval_ref_t<_Tp>> { static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), "template argument must be a complete class or an unbounded array"); @@ -1079,7 +1076,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION /// is_nothrow_constructible template struct is_nothrow_constructible - : public __is_nothrow_constructible_impl<_Tp, _Args...>::type + : public __is_nothrow_constructible_impl<_Tp, _Args...> { static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), "template argument must be a complete class or an unbounded array"); @@ -1088,112 +1085,68 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION /// is_nothrow_default_constructible template struct is_nothrow_default_constructible - : public __bool_constant<__is_nothrow_constructible(_Tp)> + : public __is_nothrow_constructible_impl<_Tp> { static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), "template argument must be a complete class or an unbounded array"); }; - /// @cond undocumented - template::value> - struct __is_nothrow_copy_constructible_impl; - - template - struct __is_nothrow_copy_constructible_impl<_Tp, false> - : public false_type { }; - - template - struct __is_nothrow_copy_constructible_impl<_Tp, true> - : public __is_nothrow_constructible_impl<_Tp, const _Tp&> - { }; - /// @endcond - /// is_nothrow_copy_constructible template struct is_nothrow_copy_constructible - : public __is_nothrow_copy_constructible_impl<_Tp>::type + : public __is_nothrow_constructible_impl<_Tp, __add_lval_ref_t> + { + static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), + "template argument must be a complete class or an unbounded array"); + }; + + /// is_nothrow_move_constructible + template + struct is_nothrow_move_constructible + : public __is_nothrow_constructible_impl<_Tp, __add_rval_ref_t<_Tp>> { static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), "template argument must be a complete class or an unbounded array"); }; /// @cond undocumented - template::value> - struct __is_nothrow_move_constructible_impl; - - template - struct __is_nothrow_move_constructible_impl<_Tp, false> - : public false_type { }; - - template - struct __is_nothrow_move_constructible_impl<_Tp, true> - : public __is_nothrow_constructible_impl<_Tp, _Tp&&> - { }; + template + using __is_assignable_impl = __bool_constant<__is_assignable(_Tp, _Up)>; /// @endcond - /// is_nothrow_move_constructible - template - struct is_nothrow_move_constructible - : public __is_nothrow_move_constructible_impl<_Tp>::type - { - static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), - "template argument must be a complete class or an unbounded array"); - }; - /// is_assignable template struct is_assignable - : public __bool_constant<__is_assignable(_Tp, _Up)> + : public __is_assignable_impl<_Tp, _Up> { static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), "template argument must be a complete class or an unbounded array"); }; - template::value> - struct __is_copy_assignable_impl; - - template - struct __is_copy_assignable_impl<_Tp, false> - : public false_type { }; - - template - struct __is_copy_assignable_impl<_Tp, true> - : public __bool_constant<__is_assignable(_Tp&, const _Tp&)> - { }; - /// is_copy_assignable template struct is_copy_assignable - : public __is_copy_assignable_impl<_Tp>::type + : public __is_assignable_impl<__add_lval_ref_t<_Tp>, + __add_lval_ref_t> { static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), "template argument must be a complete class or an unbounded array"); }; - template::value> - struct __is_move_assignable_impl; - - template - struct __is_move_assignable_impl<_Tp, false> - : public false_type { }; - - template - struct __is_move_assignable_impl<_Tp, true> - : public __bool_constant<__is_assignable(_Tp&, _Tp&&)> - { }; - /// is_move_assignable template struct is_move_assignable - : public __is_move_assignable_impl<_Tp>::type + : public __is_assignable_impl<__add_lval_ref_t<_Tp>, __add_rval_ref_t<_Tp>> { static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), "template argument must be a complete class or an unbounded array"); }; + /// @cond undocumented template using __is_nothrow_assignable_impl = __bool_constant<__is_nothrow_assignable(_Tp, _Up)>; + /// @endcond /// is_nothrow_assignable template @@ -1204,52 +1157,36 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION "template argument must be a complete class or an unbounded array"); }; - template::value> - struct __is_nt_copy_assignable_impl; - - template - struct __is_nt_copy_assignable_impl<_Tp, false> - : public false_type { }; - - template - struct __is_nt_copy_assignable_impl<_Tp, true> - : public __is_nothrow_assignable_impl<_Tp&, const _Tp&> - { }; - /// is_nothrow_copy_assignable template struct is_nothrow_copy_assignable - : public __is_nt_copy_assignable_impl<_Tp> + : public __is_nothrow_assignable_impl<__add_lval_ref_t<_Tp>, + __add_lval_ref_t> { static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), "template argument must be a complete class or an unbounded array"); }; - template::value> - struct __is_nt_move_assignable_impl; - - template - struct __is_nt_move_assignable_impl<_Tp, false> - : public false_type { }; - - template - struct __is_nt_move_assignable_impl<_Tp, true> - : public __is_nothrow_assignable_impl<_Tp&, _Tp&&> - { }; - /// is_nothrow_move_assignable template struct is_nothrow_move_assignable - : public __is_nt_move_assignable_impl<_Tp> + : public __is_nothrow_assignable_impl<__add_lval_ref_t<_Tp>, + __add_rval_ref_t<_Tp>> { static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), "template argument must be a complete class or an unbounded array"); }; + /// @cond undocumented + template + using __is_trivially_constructible_impl + = __bool_constant<__is_trivially_constructible(_Tp, _Args...)>; + /// @endcond + /// is_trivially_constructible template struct is_trivially_constructible - : public __bool_constant<__is_trivially_constructible(_Tp, _Args...)> + : public __is_trivially_constructible_impl<_Tp, _Args...> { static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), "template argument must be a complete class or an unbounded array"); @@ -1258,7 +1195,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION /// is_trivially_default_constructible template struct is_trivially_default_constructible - : public __bool_constant<__is_trivially_constructible(_Tp)> + : public __is_trivially_constructible_impl<_Tp> { static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), "template argument must be a complete class or an unbounded array"); @@ -1294,98 +1231,54 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION __is_implicitly_default_constructible_safe<_Tp>> { }; - template::value> - struct __is_trivially_copy_constructible_impl; - - template - struct __is_trivially_copy_constructible_impl<_Tp, false> - : public false_type { }; - - template - struct __is_trivially_copy_constructible_impl<_Tp, true> - : public __and_<__is_copy_constructible_impl<_Tp>, - integral_constant> - { }; - /// is_trivially_copy_constructible template struct is_trivially_copy_constructible - : public __is_trivially_copy_constructible_impl<_Tp> + : public __is_trivially_constructible_impl<_Tp, __add_lval_ref_t> { static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), "template argument must be a complete class or an unbounded array"); }; - template::value> - struct __is_trivially_move_constructible_impl; - - template - struct __is_trivially_move_constructible_impl<_Tp, false> - : public false_type { }; - - template - struct __is_trivially_move_constructible_impl<_Tp, true> - : public __and_<__is_move_constructible_impl<_Tp>, - integral_constant> - { }; - /// is_trivially_move_constructible template struct is_trivially_move_constructible - : public __is_trivially_move_constructible_impl<_Tp> + : public __is_trivially_constructible_impl<_Tp, __add_rval_ref_t<_Tp>> { static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), "template argument must be a complete class or an unbounded array"); }; + /// @cond undocumented + template + using __is_trivially_assignable_impl + = __bool_constant<__is_trivially_assignable(_Tp, _Up)>; + /// @endcond + /// is_trivially_assignable template struct is_trivially_assignable - : public __bool_constant<__is_trivially_assignable(_Tp, _Up)> + : public __is_trivially_assignable_impl<_Tp, _Up> { static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), "template argument must be a complete class or an unbounded array"); }; - template::value> - struct __is_trivially_copy_assignable_impl; - - template - struct __is_trivially_copy_assignable_impl<_Tp, false> - : public false_type { }; - - template - struct __is_trivially_copy_assignable_impl<_Tp, true> - : public __bool_constant<__is_trivially_assignable(_Tp&, const _Tp&)> - { }; - /// is_trivially_copy_assignable template struct is_trivially_copy_assignable - : public __is_trivially_copy_assignable_impl<_Tp> + : public __is_trivially_assignable_impl<__add_lval_ref_t<_Tp>, + __add_lval_ref_t> { static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), "template argument must be a complete class or an unbounded array"); }; - template::value> - struct __is_trivially_move_assignable_impl; - - template - struct __is_trivially_move_assignable_impl<_Tp, false> - : public false_type { }; - - template - struct __is_trivially_move_assignable_impl<_Tp, true> - : public __bool_constant<__is_trivially_assignable(_Tp&, _Tp&&)> - { }; - /// is_trivially_move_assignable template struct is_trivially_move_assignable - : public __is_trivially_move_assignable_impl<_Tp> + : public __is_trivially_assignable_impl<__add_lval_ref_t<_Tp>, + __add_rval_ref_t<_Tp>> { static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}), "template argument must be a complete class or an unbounded array"); @@ -1669,33 +1562,15 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION struct remove_reference<_Tp&&> { typedef _Tp type; }; - template::value> - struct __add_lvalue_reference_helper - { typedef _Tp type; }; - - template - struct __add_lvalue_reference_helper<_Tp, true> - { typedef _Tp& type; }; - /// add_lvalue_reference template struct add_lvalue_reference - : public __add_lvalue_reference_helper<_Tp> - { }; - - template::value> - struct __add_rvalue_reference_helper - { typedef _Tp type; }; - - template - struct __add_rvalue_reference_helper<_Tp, true> - { typedef _Tp&& type; }; + { using type = __add_lval_ref_t<_Tp>; }; /// add_rvalue_reference template struct add_rvalue_reference - : public __add_rvalue_reference_helper<_Tp> - { }; + { using type = __add_rval_ref_t<_Tp>; }; #if __cplusplus > 201103L /// Alias template for remove_reference