"Mark Storer"
Couldn't you do something along the lines of:
template < typename PointerT, typeName RefereceT = &(*PointerT) >
Try to compile your code ...
Only I think that's an address rather than a reference...
How about:
template < typename T > void f( T *ptr ) { T &ref = *ptr; // ... do something with ref ... }
I didn't tell that PointerT is T*. You forgot about smart pointers and iterators.
And what do you have against "->"? I don't think a reference's "." is any faster than a pointer's "->", so that shouldn't be a concern... just
trying
to save some knuckle grease?
I hope it was not offensive.
I don't get it. (I'm getting a lot of practice with that phrase since I started digging into STL & Boost)
1) The problem is not related to raw pointers, but to smart ones. 2) I have nothing against "->". 3) ReferenceT is not always T&, it can also be some kind of proxy or simply value type, or even void (for input iterator). 4) The original problem (for me) was in creating generic "dereference" function: <code> template <typename PointerT > ReferenceT dereference( PointerT ptr ) { return *ptr; } <\code> Have you any ideas on how to distinguish ReferenceT in this case ? --------------------------------------- Take a look at boost.devel for more details.