Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 27 Dec 2007 16:21:11 +0100
From:      "Heiko Wundram (Beenic)" <wundram@beenic.net>
To:        freebsd-hackers@freebsd.org
Subject:   OT: C++ Template Functions
Message-ID:  <200712271621.12167.wundram@beenic.net>

next in thread | raw e-mail | index | archive | help
Hey all!

I'm currently trying to implement (and use) a C++ member function template,=
=20
but GCC won't eat the code I feed it.

The problem is most probably related to the fact that the group of member=20
functions is only discriminated by return type (i.e., the template paramete=
r=20
defines the return type), not by parameter (which could be inferred).

=46rom what I gather, the C++ spec should allow the following code to work =
(the=20
following is simplified from what I have, but pretty much the same=20
syntactically):

"""
template <typename U>
class Test
{

public:

	template <typename V>
	V test()
		throw()
	{
		// Some stuff.
	}

};

template <typename U, typename V>
void test2()
	throw()
{
	Test<V>* x =3D new Test<V>();
	x->test<U>();
	delete x;
}

int main(int argc, char** argv)
{
	test2<int,short>();
}
"""

gcc doesn't compile this code, no matter what I try to change the x->test<U=
>=20
expression to. It does compile the code if the type of x is not defined via=
 a=20
template parameter in test2.

If this is against the specs, please tell me, otherwise, looking forward to=
=20
any hints on what may cause this!

=2D-=20
Heiko Wundram
Product & Application Development
=2D------------------------------------
Office Germany - EXPO PARK HANNOVER
=20
Beenic Networks GmbH
Mail=E4nder Stra=DFe 2
30539 Hannover
=20
=46on        +49 511 / 590 935 - 15
=46ax        +49 511 / 590 935 - 29
Mobil      +49 172 / 43 737 34
Mail       wundram@beenic.net


Beenic Networks GmbH
=2D------------------------------------
Sitz der Gesellschaft: Hannover
Gesch=E4ftsf=FChrer: Jorge Delgado
Registernummer: HRB 61869
Registergericht: Amtsgericht Hannover



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200712271621.12167.wundram>