c++/730: Cannot explicitly specify template parameters of function

brcordie@hotmail.com brcordie@hotmail.com
Fri Nov 3 05:06:00 GMT 2000


>Number:         730
>Category:       c++
>Synopsis:       Cannot explicitly specify template parameters of function
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          rejects-legal
>Submitter-Id:   net
>Arrival-Date:   Fri Nov 03 05:06:01 PST 2000
>Closed-Date:
>Last-Modified:
>Originator:     brcordie@hotmail.com
>Release:        g++-2.91.66
>Organization:
>Environment:
Linux running on PC
>Description:
As demonstrated in the following code the compiler won't 
allow me to explicitly specify the template parameters to 
the template functions f2() or f4() which is neccisary 
because they cannot be deduced from the parameter list.
The compiler cites a parse error befor the '>' on the indicated
lines.

I could add a bogus parameter but that won't work if the 
template parameter is a value rather than a type.

If there is a way around this please email me.

Thanks.

//******** begin code

#include <iostream>

template <class A> struct O {
	template <class B> static void f1(B b) {cout << "in static function f1" << endl;};
	template <class B> static void f2() {cout << "in static function f2" << endl;};
	template <class B> void f3(B b) {cout << "in nonstatic function f3" << endl;};
	template <class B> void f4() {cout << "in nonstatic function f4" << endl;};
};

template <class A> void g1() {cout << "inside global function" << endl;};

main()
{
	
	O<int>::f1(33);
	g1<int>();         
	O<int>::f2<int>(); //Produces parse error
	O<int> o;
	o.f3(33);
	o.f4<int>();       //Produces parse error
}
//************ end code
>How-To-Repeat:

>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the Gcc-bugs mailing list