What is needed is not a pointer to the managed class, but a pointer to the structure of the unmanaged code, the pointer of which I write in the class field (managed), then I want to reload the & operator to be able to extract the address of the pointer that is written in the field (not the managed class address). In this case, so that there would be no memory leaks, and users could not change this field, which can not be changed outside / inside the class. It should be one for the entire life cycle of the class.
I don’t understand anything, if I overloaded the & operator in the c ++ - cli library , then when trying to extract the real address of a pointer whose value is closed from external access (native pointer void* ) , c # suddenly tells me:
Cannot get address, determine size, or declare pointer to managed type ("vlc_instance").
Class example:
public ref class SomePtr { private: void* m_hide_ptr_; SomePtr(): m_hide_ptr_(nullptr) { m_hide_ptr = get_native_ptr(); // Не указатель на управляемый объект! } // static // Оставим static на всякий, вдруг кто подумает что что-то не то void*& operator &(const SomePtr^ value) { return value->m_hide_ptr_; } ... } Doesn't operator overloading help here?
GChas the right to move the structures created by unmanaged code to c . - LLENN