public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "redi at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/102780] Checking constraints using large fold expression is slow Date: Fri, 15 Oct 2021 13:26:16 +0000 [thread overview] Message-ID: <bug-102780-4-gTZ93nmdM4@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-102780-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102780 --- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> --- In the real code, I find that a separate constrained specialization like this: template<typename T, typename... U> union variadic_union<T, U...> { T first; variadic_union<U...> rest; static constexpr int size = variadic_union<U...>::size + 1; }; template<typename T, typename... U> requires (!trivially_destructible<T, U...>) union variadic_union<T, U...> { variadic_union(const variadic_union&) = default; variadic_union(variadic_union&&) = default; variadic_union& operator=(const variadic_union&) = default; variadic_union& operator=(variadic_union&&) = default; // Non-trivial dtor is required for this partial specialization constexpr ~variadic_union() { } T first; variadic_union<U...> rest; static constexpr int size = variadic_union<U...>::size + 1; }; Is much faster (14s instead of 20s+) than a constrained destructor in the primary template: template<typename T, typename... U> union variadic_union<T, U...> { variadic_union(const variadic_union&) = default; variadic_union(variadic_union&&) = default; variadic_union& operator=(const variadic_union&) = default; variadic_union& operator=(variadic_union&&) = default; ~variadic_union() = default; // Conditionally non-trivial dtor, if required. constexpr ~variadic_union() requires (!trivially_destructible<T, U...>) { } T first; variadic_union<U...> rest; static constexpr int size = variadic_union<U...>::size + 1; }; I haven't been able to reproduce that time difference in the reduced examples though.
next prev parent reply other threads:[~2021-10-15 13:26 UTC|newest] Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-10-15 13:12 [Bug c++/102780] New: " redi at gcc dot gnu.org 2021-10-15 13:14 ` [Bug c++/102780] " redi at gcc dot gnu.org 2021-10-15 13:26 ` redi at gcc dot gnu.org [this message] 2021-10-15 14:32 ` redi at gcc dot gnu.org 2021-10-28 14:05 ` cvs-commit at gcc dot gnu.org 2021-10-28 14:49 ` ppalka at gcc dot gnu.org 2022-12-16 21:11 ` cvs-commit at gcc dot gnu.org 2022-12-16 21:14 ` cvs-commit at gcc dot gnu.org 2022-12-16 23:57 ` ppalka at gcc dot gnu.org 2024-01-07 1:00 ` cvs-commit at gcc dot gnu.org
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=bug-102780-4-gTZ93nmdM4@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@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).