public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: "vagran.ast" <vagran.ast@gmail.com>
To: gcc-help@gcc.gnu.org
Subject: Template argument (pointer to member function) initialization with NULL
Date: Mon, 14 Nov 2011 21:48:00 -0000	[thread overview]
Message-ID: <4EC1789A.2070209@gmail.com> (raw)

Hi,

In the following code:

class A {
public:
     void SomeMethod() { }
};

template <class T, void (T::*SomeMethod)() = 0>
class B {

};

B<A> b1; // error: could not convert template argument '0' to 'void 
(A::*)()'

B<A, 0> b2; // error: could not convert template argument '0' to 'void 
(A::*)()'

void (A::*someMethod)() = 0; // OK

there are two compilation errors. AFAIK per C++ standard 0 is a valid 
value for a pointer to member
function. Variable of such type can be successfully initialized by 0 but 
template arguments can not.
Is it desired behavior or a bug?

gcc version 4.6.1

             reply	other threads:[~2011-11-14 20:23 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-14 21:48 vagran.ast [this message]
2011-11-14 21:51 ` Jonathan Wakely
2011-11-15 13:15   ` vagran.ast
2011-11-15 19:55     ` Jonathan Wakely
2011-11-16 21:11       ` vagran.ast

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=4EC1789A.2070209@gmail.com \
    --to=vagran.ast@gmail.com \
    --cc=gcc-help@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: link
Be 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).