public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "de34 at live dot cn" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/113060] std::variant converting constructor/assignment is non-conforming after P2280? Date: Mon, 19 Feb 2024 08:07:38 +0000 [thread overview] Message-ID: <bug-113060-4-7MEtUBsHrL@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-113060-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113060 Jiang An <de34 at live dot cn> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |de34 at live dot cn --- Comment #4 from Jiang An <de34 at live dot cn> --- Hi, I found that we can support std::variant<float>(IC{}) with C++17 core language rules (as modified by P2280R4), and thus P3146 should be updated. Proof-of-concept example (https://gcc.godbolt.org/z/174sx397f): ``` #include <type_traits> #include <utility> template<class Ti> struct array_element_initialization_tester { Ti elems[1]; }; template<class Ti, class Tp> auto test_array_element_initializable(Tp&& t) -> decltype((void) array_element_initialization_tester<Ti>{{std::forward<Tp>(t)}}); template<class Ti, class Tp, class = void> constexpr bool is_array_element_initializable_from = false; template<class Ti, class Tp> constexpr bool is_array_element_initializable_from<Ti, Tp, decltype(::test_array_element_initializable<Ti>(std::declval<Tp>()))> = true; template <typename T, std::enable_if_t<is_array_element_initializable_from<float, T>, int> = 0> void FUN(float); int main() { using IC = std::integral_constant<int, 42>; FUN<IC>(IC{}); IC ic; FUN<IC&>(ic); } ``` Note that this example adds a mediate function template (test_array_element_initializable) to "reduce" the non-constexpr-ness of std::declval.
next prev parent reply other threads:[~2024-02-19 8:07 UTC|newest] Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-12-18 9:32 [Bug libstdc++/113060] New: " dangelog at gmail dot com 2023-12-18 11:18 ` [Bug libstdc++/113060] " redi at gcc dot gnu.org 2023-12-18 14:32 ` dangelog at gmail dot com 2024-02-16 14:43 ` redi at gcc dot gnu.org 2024-02-19 8:07 ` de34 at live dot cn [this message] 2024-02-19 9:07 ` de34 at live dot cn 2024-02-19 9:11 ` de34 at live dot cn 2024-02-19 23:47 ` dangelog at gmail dot com 2024-02-20 1:47 ` de34 at live dot cn 2024-02-20 10:09 ` dangelog at gmail dot com
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-113060-4-7MEtUBsHrL@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).