member template explicit qualification in VC6
Balachandran Natarajan
bala at dre.vanderbilt.edu
Mon Dec 15 12:56:25 CST 2003
hi
On Monday, 15 December, 2003 at 10:12:43 -0600, David Hanak wrote:
> On Sat, 13 Dec 2003, Attila Vizhanyo wrote:
>
> > Consider the following C++ class definition:
> > [...]
> > typedef int T;
> > T t= a.getT(); // return types are not used in template parameter deduction
>
> Well, I don't know how to do it officially (or if it's possible at all),
> but there's a workaround: use a dummy argument of the same type.
>
> class A
> {
> public:
> template <class T> T& getT(T t);
> };
>
> And then
>
> A a;
> int i = a.getT(0);
>
> should do the trick.
This is called a "royal hack" in some parts of the globe :-)! What
happens if one start using ADT's defined by the application? What
happens if the data types have some of the operators private or
protected? I would as well expose an interface that works across
the board ( <shameless plug> see what we do in TAO </shameless plug>)
instead of handling ints, doubles, ADT's, vectors<> etc. on a
case-by-case basis.
Back to work!
Thanks
Bala
More information about the gme-users
mailing list