" (membership access) recursively I learn how to overload "->" and the documentation says: "operator-> is called again by the va...">

Overloading "->" (membership access) recursively

I learn how to overload "->" and the documentation says: "operator-> is called again by the value it returns, recursively, until the operator-> is reached, which returns a simple pointer. After that, this pointer has built-in semantics. "

So far it’s clear what the documentation says, in fact, that the overloaded “->” class can use the “special pointer” itself, which has the overloaded “->”, which can give the “special pointer”, etc. etc. until a "simple pointer" is found, I cannot find an example of its real use (unless it is used to search for a linked list of the last element).

Can someone explain what retionale is behind the scenes (since this feature is not provided to "simple pointers", so I see no reason to provide it with "special pointers").

An example of using the real world can also help, since I probably lack a model where behavior can be applied.

On the opposite side, it may be necessary to avoid this behavior, how can this be done?

+4
source share
2 answers

I can not find an example of its real use (unless it is used to search for a linked list of the last item).

, , . . , operator->, , , operator->, , . , x->->->i not x->next->next->next,

, , , , .

Execute Around Pointer.

, ?

:

auto x = p.operator->();
+2

, -> .

- . pointer->member : "" . "" , ++ . , . "" . - , , ++ . ( --, ).

->: , -> (, ), , ? . - : -> - . , , .

-> : -> .. , ->. : "" () -> ( ) ( ).

, , , "" ->. sptr, member, , . sptr->member. sptr->->member sptr->.member - "" ->.

, ->, .. object->member. , -, ->, . object.operator ->(). , -> . . ->, -> (, ->, int), object.operator ->() . object->member .

+7

All Articles