Topic: operator-> overloading
Author: jr@grenoble.hp.com (Jean-Rene Bouvier)
Date: Fri, 14 Oct 1994 06:59:23 GMT Raw View
Operator-> can be overloaded for any class of object, but the overloading
mechanism doesn't allow for passing information about the field referenced
by the operator. In other words, if we have the following definitions,
class A { public: int i; char c; };
class B { public: A* operator->(); /* ... */ };
A* a;
B b;
there's no way for operator-> to behave differently whether b->i or b->c
is used. In a number of applications, you'd want this operator to be able
to discriminate both on the type and the offset of the dereferenced field
(e.g. when writing ASN.1 to C++ compilers). More precisely, you'd want
to be able to rewrite class B as:
class B { public: A* template<class T> operator->(T A::* pma); };
(By the way, is it legal now to have template member functions ?).
This extensions could easily be made compatible with the existing mechanism.
Has such an extension been discussed within the ANSI committee ?
Jean-Rene Bouvier.
ps: as I'm an occasional reader of notes, could responders to this
thread also cc: my email address ? Thanks.
______________________________________________________________________
| |
|Jean-Rene Bouvier Unix Mail: jean-rene_bouvier@grenoble.hp.com|
|TNO B1L2G3 - box 18 Telephone: +33 7662 1389 |
|Hewlett-Packard France Fax: +33 7662 1488 |
|5 av R. Chanas - Eybens X400: c=FR,a=ATLAS,p=HP,o=HP, |
|38053 Grenoble Cedex 09 ou1=HP6300,g=Jean-Rene,s=BOUVIER |
|______________________________________________________________________|