g++ Template call through pointer - a bug?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

Here is a short program that fail to compile with single error that I can not
explain. Here I try to call a member function template via pointer to object.
Seemingly the same code compiles in one context and fails in other with syntax
error. I would not claim this is a bug, but it does look like one to me. What
am I missing here? gcc version 3.3.3 (mingw special)

Thanks
Vladimir

-------------------------
#include <stdio.h>
struct A {
	template <class T> void fun() {
		printf("%d\n",sizeof(T));
	}
};

struct B {
	A *a;
	B(A *ia) {
		a = ia;
	}
	template <class T> void fun() {
		a->fun<T>(); // This works
	}
};

template <class T> void ptrfun(A* a) {
	a->fun<T>(); // tst.cpp:19: error: syntax error before `>' token
}

int main() {
	A a;
	B b(&a);

	a.fun<int>();
	b.fun<double>();
	ptrfun<char>(&a);	
}
-------------------------------------------


		
__________________________________ 
Yahoo! Messenger 
Show us what our next emoticon should look like. Join the fun. 
http://www.advision.webevents.yahoo.com/emoticontest

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux