By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,655 Members | 964 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,655 IT Pros & Developers. It's quick & easy.

taking address of a template method

P: n/a
hello,

i have the following problem: taking the pointer of a particular
instantiation of template member function A::f. i have no idea of how
achieve in the intent. :(

any halp or hint would be very appreciated.

cheers
domenico

struct A
{
template <typename T>
void f(const T& t) { ... }
};

void g(void (A::* f)(const int&))
{
...
}

int main()
{
void (A::* x)(const int&) = &(A::template f<int>);
g(x);

...
}
-----[ Domenico Andreoli, aka cavok
--[ http://filibusta.crema.unimi.it/~cavok/gpgkey.asc
---[ 3A0F 2F80 F79C 678A 8936 4FEE 0677 9033 A20E BC50
Jul 19 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
"Domenico Andreoli" <ca***@cavok.dyndns.org> wrote...
i have the following problem: taking the pointer of a particular
instantiation of template member function A::f. i have no idea of how
achieve in the intent. :(

any halp or hint would be very appreciated.

cheers
domenico

struct A
{
template <typename T>
void f(const T& t) { ... }
};

void g(void (A::* f)(const int&))
{
...
}

int main()
{
void (A::* x)(const int&) = &(A::template f<int>);
g(x);

...
}


This:

struct A
{
template <typename T> void f(const T& t) {}
};

void g(void (A::*f)(const int&))
{
A a;
(a.*f)(42);
}

int main()
{
void (A::* x)(const int&) = &A::f<int>;
g(x);
}

compiles for me, as expected.

What error messages do you get, if any?

Victor
Jul 19 '05 #2

P: n/a
In article <vj************@corp.supernews.com>, Victor Bazarov wrote:
This:

struct A
{
template <typename T> void f(const T& t) {}
};

void g(void (A::*f)(const int&))
{
A a;
(a.*f)(42);
}

int main()
{
void (A::* x)(const int&) = &A::f<int>;
g(x);
}

compiles for me, as expected.

What error messages do you get, if any?

none. thanks to your confirmation i found it was my fault elsewhere.

i do not even need to explicate the instantiation, compiler guesses it
from the signature of the pointer x.

many thanks again
domenico

-----[ Domenico Andreoli, aka cavok
--[ http://filibusta.crema.unimi.it/~cavok/gpgkey.asc
---[ 3A0F 2F80 F79C 678A 8936 4FEE 0677 9033 A20E BC50
Jul 19 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.