This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/16320] New: Rejects explicit template parameter type passing for member templates


Template member method cannot be called from within another template function or template class if 
the compiler cannot deduce template parameter types itself. The compiler rejects explicit template 
parameter type passing in this case. If template parameter types are passed explicitly to member 
template from non-template function or method, everything is ok. Here is the example:

class A {
public:
	template <class T> void f() {} // T not "deducable"
	template <class T> void f(T) {} // T "deducable"
};

void f(A& a)
{
	a.f<int>(); // ok
	a.f(int(0)); // ok
}

template <class T> void ft(A& a) // same as f(), but template
{
	a.f<int>(); // error: parse error before '>' token 
	a.f(int(0)); // ok
}

int main (int argc, char * const argv[]) {
	A a;
	a.f<int>(); 
	a.f(int(0));
	f(a);
	ft<int>(a);
	return 0;
}

-- 
           Summary: Rejects explicit template parameter type passing for
                    member templates
           Product: gcc
           Version: 3.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: jiri dot volejnik at volny dot cz
                CC: gcc-bugs at gcc dot gnu dot org
  GCC host triplet: powerpc-mac-os x


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16320


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]