This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
[Q] Declaration of the pointer to the function template??
- To: egcs at cygnus dot com
- Subject: [Q] Declaration of the pointer to the function template??
- From: Miljenko Moljac Cvjetko gcl++ Library Development <m dot cvjetko_nO_spaM at rt dot e-technik dot uni-erlangen dot de>
- Date: Wed, 12 May 1999 22:22:36 +0200
- Newsgroups: comp.lang.c++,comp.lang.c++.moderated
- Organization: Miljenko Moljac Cvjetko gcl++ Library Development Uni Erlangen
- Reply-To: m dot cvjetko_nO_spam at rt dot e-technik dot uni-erlangen dot dot de
/*
newsgroups:
comp.lang.c++
comp.lang.c++.moderated
reply to :
vcvjetko@linux.rulz.zg.tel.hr
m.cvjetko@linux.rulz.rt.e-technik.uni-erlangen.de
by removing praising the best OS
[Q] Declaration of the pointer to the function template??
Hello!
Is it possible to declare pointer to function template?? And if it
is how could it be done??
Thanx in advance!
miljenko
Here's what I've tried:
*/
# include <algorithm>
template<class Type>
Type (*fptr) (Type a, Type b);
int main()
{
fptr = &std::min;
(*fptr)(1,2);
fptr = &std::max;
(*fptr)(1,2);
return 0;
};
/*
gcl@moljac:~/gcl/src/example/Tests/syntax_standard_comformance > g++ -v
pointer_to_function_template_TO_ASK.cpp
Reading specs from /usr/lib/gcc-lib/i586-pc-linux-gnu/egcs-2.91.66/specs
gcc version egcs-2.91.66 19990314 (egcs-1.1.2 release)
/usr/lib/gcc-lib/i586-pc-linux-gnu/egcs-2.91.66/cpp -lang-c++ -v -undef
-D__GNUC__=2 -D__GNUG__=2 -D__cplusplus -D__GNUC_MINOR__=91 -D__ELF__
-Dunix -Di386 -D__i386__ -Dlinux -D__ELF__ -D__unix__ -D__i386__
-D__i386__ -D__linux__ -D__unix -D__i386 -D__linux -Asystem(posix)
-D__EXCEPTIONS -Asystem(unix) -Acpu(i386) -Amachine(i386) -Di386
-D__i386 -D__i386__ -Di586 -Dpentium -D__i586 -D__i586__ -D__pentium
-D__pentium__ pointer_to_function_template_TO_ASK.cpp /tmp/ccXNKyoi.ii
GNU CPP version egcs-2.91.66 19990314 (egcs-1.1.2 release) (i386
Linux/ELF)
#include "..." search starts here:
#include <...> search starts here:
/usr/include/g++
/usr/local/include
/usr/i586-pc-linux-gnu/include
/usr/lib/gcc-lib/i586-pc-linux-gnu/egcs-2.91.66/include
/usr/include
End of search list.
/usr/lib/gcc-lib/i586-pc-linux-gnu/egcs-2.91.66/cc1plus
/tmp/ccXNKyoi.ii -quiet -dumpbase pointer_to_function_template_TO_ASK.cc
-version -o /tmp/ccePFpdS.s
GNU C++ version egcs-2.91.66 19990314 (egcs-1.1.2 release)
(i586-pc-linux-gnu) compiled by GNU C version egcs-2.91.66 19990314
(egcs-1.1.2 release).
pointer_to_function_template_TO_ASK.cpp:28: template declaration of
`Type (* fptr)(Type, Type)'
pointer_to_function_template_TO_ASK.cpp: In function `int main()':
pointer_to_function_template_TO_ASK.cpp:32: non-lvalue in assignment
pointer_to_function_template_TO_ASK.cpp:34: parameter type of called
function is incomplete
pointer_to_function_template_TO_ASK.cpp:34: parameter type of called
function is incomplete
pointer_to_function_template_TO_ASK.cpp:34: invalid use of template type
parameter
pointer_to_function_template_TO_ASK.cpp:36: non-lvalue in assignment
pointer_to_function_template_TO_ASK.cpp:38: parameter type of called
function is incomplete
pointer_to_function_template_TO_ASK.cpp:38: parameter type of called
function is incomplete
pointer_to_function_template_TO_ASK.cpp:38: invalid use of template type
parameter
*/