This question already has an answer here:
- Overloading member access operators ->, .* (C++) 7 answers
- How to overload -> operator in C++ Proxy Pattern 1 answer
As per the title, how to overload -> operator in C++?
I can't find any documentation.
cppreference glosses over it.
The Wikipedia page on overloading similarly glosses over it.
Operator overloading <-- this SO post again has a '->' shaped hole in it, although one comment gives a hint:
operator->() is actually extremely weird. It's not required to return a value_type* -- in fact, it can return another class type, provided that class type has an operator->(), which will then be called subsequently. This recursive calling of operator->()s proceeds until a value_type* return type occurs. Madness! :)
It appears that this particular operator is not straightforward to overload.
Could someone link to documentation, or (preferably) provide some here?
PS I recognisze this is an unusual overload, I have need of it in a Proxy pattern, here
Aucun commentaire:
Enregistrer un commentaire