public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "antoshkka at gmail dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/55576] Fails to compile a call to template member function Date: Tue, 04 Dec 2012 07:13:00 -0000 [thread overview] Message-ID: <bug-55576-4-cSg3UTqQXu@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-55576-4@http.gcc.gnu.org/bugzilla/> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55576 Antony Polukhin <antoshkka at gmail dot com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |UNCONFIRMED Resolution|INVALID | --- Comment #3 from Antony Polukhin <antoshkka at gmail dot com> 2012-12-04 07:12:12 UTC --- (In reply to comment #1) > I don't think this is a G++ bug, there are three problems with this code: > > 1) You need to #include <new> to use placement new > 2) factory::apply is non-const but the parameter 'f' is const Fixed > 3) f.template apply<T> finds the current instantiation, ::apply<T>, rather than > the member function you are trying to call, use f.FactoryT::template apply<T> > instead That is the point. `f.template apply<T>(address);` is accepted by some compilers without `FactoryT::` Fixed version: struct factory { template <typename T> void * apply(void * address) const { return 0; } }; template <typename T> struct apply { template <typename FactoryT> void* operator()(FactoryT const& f, void * address) const { return f.template apply<T>(address); // error: invalid use of ‘struct apply<T>’ why??? } }; int main() { int place; apply<int>()(factory(), &place); return 0; }
next prev parent reply other threads:[~2012-12-04 7:13 UTC|newest] Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top 2012-12-03 15:27 [Bug c++/55576] New: " antoshkka at gmail dot com 2012-12-03 16:01 ` [Bug c++/55576] " redi at gcc dot gnu.org 2012-12-03 16:08 ` paolo.carlini at oracle dot com 2012-12-04 7:13 ` antoshkka at gmail dot com [this message] 2012-12-04 9:38 ` paolo.carlini at oracle dot com 2012-12-04 10:48 ` glisse at gcc dot gnu.org 2012-12-04 11:05 ` redi at gcc dot gnu.org 2012-12-06 14:39 ` antoshkka at gmail dot com 2012-12-06 15:47 ` redi at gcc dot gnu.org 2012-12-06 16:33 ` jason at gcc dot gnu.org 2012-12-13 18:02 ` tudorb at fb dot com 2012-12-13 18:04 ` tudorb at fb dot com 2013-02-25 14:07 ` potswa at mac dot com 2013-02-25 16:20 ` d.frey at gmx dot de 2013-03-16 9:45 ` paolo.carlini at oracle 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-55576-4-cSg3UTqQXu@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).