public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Jonathan Wakely <redi@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc r12-2996] libstdc++: Simplify n-ary arithmetic promotion traits Date: Wed, 18 Aug 2021 14:36:19 +0000 (GMT) [thread overview] Message-ID: <20210818143619.85FA5388E801@sourceware.org> (raw) https://gcc.gnu.org/g:37620d575111caf3b24d4b9039808334e619c13a commit r12-2996-g37620d575111caf3b24d4b9039808334e619c13a Author: Jonathan Wakely <jwakely@redhat.com> Date: Tue Aug 17 20:26:52 2021 +0100 libstdc++: Simplify n-ary arithmetic promotion traits The std::complex partial specializations have been unnecessary since 774c3d8647cc7012937cfc9d2d6dacc85b6cf8e9 Signed-off-by: Jonathan Wakely <jwakely@redhat.com> libstdc++-v3/ChangeLog: * include/ext/type_traits.h (__promote_2, __promote_3) (__promote_4): Redfine as alias templates using __promoted_t. * include/std/complex (__promote_2): Remove partial specializations for std::complex. Diff: --- libstdc++-v3/include/ext/type_traits.h | 16 +++++++++++++++- libstdc++-v3/include/std/complex | 29 ----------------------------- 2 files changed, 15 insertions(+), 30 deletions(-) diff --git a/libstdc++-v3/include/ext/type_traits.h b/libstdc++-v3/include/ext/type_traits.h index 065edb4e9a5..fed78d3a527 100644 --- a/libstdc++-v3/include/ext/type_traits.h +++ b/libstdc++-v3/include/ext/type_traits.h @@ -189,9 +189,22 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { typedef float __type; }; #if __cpp_fold_expressions + template<typename... _Tp> using __promoted_t = decltype((typename __promote<_Tp>::__type(0) + ...)); -#endif + + // Deducing the promoted type is done by __promoted_t<_Tp...>, + // then __promote is used to provide the nested __type member. + template<typename _Tp, typename _Up> + using __promote_2 = __promote<__promoted_t<_Tp, _Up>>; + + template<typename _Tp, typename _Up, typename _Vp> + using __promote_3 = __promote<__promoted_t<_Tp, _Up, _Vp>>; + + template<typename _Tp, typename _Up, typename _Vp, typename _Wp> + using __promote_4 = __promote<__promoted_t<_Tp, _Up, _Vp, _Wp>>; + +#else template<typename _Tp, typename _Up, typename _Tp2 = typename __promote<_Tp>::__type, @@ -219,6 +232,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { typedef __typeof__(_Tp2() + _Up2() + _Vp2() + _Wp2()) __type; }; +#endif _GLIBCXX_END_NAMESPACE_VERSION } // namespace diff --git a/libstdc++-v3/include/std/complex b/libstdc++-v3/include/std/complex index c2f6421e0b7..a5b4406dd68 100644 --- a/libstdc++-v3/include/std/complex +++ b/libstdc++-v3/include/std/complex @@ -1557,35 +1557,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _GLIBCXX_END_NAMESPACE_VERSION } // namespace -namespace __gnu_cxx _GLIBCXX_VISIBILITY(default) -{ -_GLIBCXX_BEGIN_NAMESPACE_VERSION - - // See ext/type_traits.h for the primary template. - template<typename _Tp, typename _Up> - struct __promote_2<std::complex<_Tp>, _Up> - { - public: - typedef std::complex<typename __promote_2<_Tp, _Up>::__type> __type; - }; - - template<typename _Tp, typename _Up> - struct __promote_2<_Tp, std::complex<_Up> > - { - public: - typedef std::complex<typename __promote_2<_Tp, _Up>::__type> __type; - }; - - template<typename _Tp, typename _Up> - struct __promote_2<std::complex<_Tp>, std::complex<_Up> > - { - public: - typedef std::complex<typename __promote_2<_Tp, _Up>::__type> __type; - }; - -_GLIBCXX_END_NAMESPACE_VERSION -} // namespace - #if __cplusplus >= 201103L namespace std _GLIBCXX_VISIBILITY(default)
reply other threads:[~2021-08-18 14:36 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20210818143619.85FA5388E801@sourceware.org \ --to=redi@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ --cc=libstdc++-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).