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 libstdc++/52917] [DR 2048] explicitly stated return type in std::mem_fn cannot be compiled Date: Mon, 09 Apr 2012 21:18:00 -0000 [thread overview] Message-ID: <bug-52917-4-QU67l9evNk@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-52917-4@http.gcc.gnu.org/bugzilla/> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52917 Jonathan Wakely <redi at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |SUSPENDED Last reconfirmed| |2012-04-09 Summary|explicitly stated return |[DR 2048] explicitly stated |type in std::mem_fn cannot |return type in std::mem_fn |be compiled |cannot be compiled Ever Confirmed|0 |1 --- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> 2012-04-09 21:18:11 UTC --- (In reply to comment #0) > (2) needs the return type to diffrentiate between the const and the non-const > getter. Or you can do auto y = std::mem_fn((int& (X::*)())&X::get ); Which also works in this case where specifying the return type doesn't help: struct X { int get() { return 0; } int get() const { return 1; } }; > The specification for mem_fn is > > template< class R, class T > /*unspecified*/ mem_fn(R T::* pm); > template< class R, class T, class... Args > /*unspecified*/ mem_fn(R (T::* > pm)(Args...)); > [ ... some more overloads for const, volatile and references] Maybe not for long: http://cplusplus.github.com/LWG/lwg-active.html#2048 The libstdc++ implementation exactly matches that issue's proposed resolution, which has been voted Tentatively Ready. > (2) should result in an instantiation of the second version with > sizeof...(Args)==0, because argument to the first version is a "pointer to > member data", not "pointer to member function". No, it's a pointer to member, which can match either a pointer to member data or pointer to member function. If the second overload exists (as it presumably does in libc++) then it's a better match than the first overload, but the first overload is still viable. > Both g++-4.7 and clang++-3.1 (when compiling with libstdc++) try to instantiate > the first version by mistake. Not by mistake, by design, that overload can match any pointer to member. I'm suspending this because I believe the resolution to DR 2048 would make libstdc++ correct.
next prev parent reply other threads:[~2012-04-09 21:18 UTC|newest] Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top 2012-04-09 19:51 [Bug libstdc++/52917] New: " freunddeslichts at web dot de 2012-04-09 21:18 ` redi at gcc dot gnu.org [this message] 2012-04-09 21:35 ` [Bug libstdc++/52917] [DR 2048] " redi at gcc dot gnu.org 2012-04-10 9:54 ` freunddeslichts at web dot de 2012-04-10 11:24 ` redi at gcc dot gnu.org 2014-05-07 16:38 ` redi 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-52917-4-QU67l9evNk@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).