OT: C++ Template Functions
- From: "Heiko Wundram (Beenic)" <wundram@xxxxxxxxxx>
- Date: Thu, 27 Dec 2007 16:21:11 +0100
Hey all!
I'm currently trying to implement (and use) a C++ member function template,
but GCC won't eat the code I feed it.
The problem is most probably related to the fact that the group of member
functions is only discriminated by return type (i.e., the template parameter
defines the return type), not by parameter (which could be inferred).
From what I gather, the C++ spec should allow the following code to work (the
following is simplified from what I have, but pretty much the same
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 = 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>
expression to. It does compile the code if the type of x is not defined via a
template parameter in test2.
If this is against the specs, please tell me, otherwise, looking forward to
any hints on what may cause this!
--
Heiko Wundram
Product & Application Development
-------------------------------------
Office Germany - EXPO PARK HANNOVER
Beenic Networks GmbH
Mailänder Straße 2
30539 Hannover
Fon +49 511 / 590 935 - 15
Fax +49 511 / 590 935 - 29
Mobil +49 172 / 43 737 34
Mail wundram@xxxxxxxxxx
Beenic Networks GmbH
-------------------------------------
Sitz der Gesellschaft: Hannover
Geschäftsführer: Jorge Delgado
Registernummer: HRB 61869
Registergericht: Amtsgericht Hannover
_______________________________________________
freebsd-hackers@xxxxxxxxxxx mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@xxxxxxxxxxx"
- Follow-Ups:
- Re: OT: C++ Template Functions
- From: Václav Haisman
- Re: OT: C++ Template Functions
- From: Erich Dollansky
- Re: OT: C++ Template Functions
- Prev by Date: Re: Synaptics
- Next by Date: Re: OT: C++ Template Functions
- Previous by thread: Re: quest for USB only mouse operation
- Next by thread: Re: OT: C++ Template Functions
- Index(es):
Relevant Pages
|
|