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

store pointer to template function

P: n/a
Do you have an example of how to use pointers to specializations of
template functions?

I have same specializations of template functions and I would like to
store and acees this functions using pointers to them. How can I do
that?

regards,
jc

Apr 18 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
jcarlos wrote:
Do you have an example of how to use pointers to specializations of
template functions?

I have same specializations of template functions and I would like to
store and acees this functions using pointers to them. How can I do
that?


What book on templates are you reading? I would expect any of them to
have an example of what you're asking about.

#include <typeinfo>
#include <string>
template<class T> std::string foo() { return typeid(T).name(); }

#include <iostream>
int main() {
std::string (*p)() = foo<int>;
std::cout << p() << " and " << foo<double>() << std::endl;
}

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Apr 18 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.