I'm using a class called Pointer, which is some kind of a wrapper around a real pointer I guess. I think this line of code in this class enables me to get the real pointer:
operator const T* () const;
What does this mean exactly? How can I call this?
Suppose myPointer
is a Pointer<int16_t>
object. I should be able to get the int_16*
object which wraps this pointer, by using the operator overloading above, but I don't know how.
Edit
Based on the answers belo, I now know I can do this:
const int16_t* myRealPointer = myPointer;
Now suppose I need to call a function which expects a int16_t*
parameter (so without the const). What can I do to pass this myRealPointer object to that function?
This is a conversion operator. For example, you could use it to convert a
Pointer<T>
to a realT*
and, additionally, use it everywhere aT*
is expected:In this case, the operator is only defined for the conversion to const raw pointers, so
float* p2 = p;
would not work. (Also there might be a similar operator for that case.)