I have a URes class which contains a single pointer to <T>, with indirection operators -> and * overloaded so I can use the instance as a pointer directly.
However I also want to be able to pass my URes instance to functions that normally take the pointer inside the URes instance.
How do I make it so that when my URes instance object is passed to a function it is automatically cast to the pointer it contains?
The same way that you create any outbound conversion: by declaring and defining an operator.
In this case, you want a member
operator T*.Example:
However, I’d recommend avoiding this and implementing a member
T* get()instead. It should be an explicit step for a calling scope to obtain a pointer from your object.