Opaque handles are used to refer to an object, but are themselves not an object. They are often implemented in terms of pointers to a type that user code knows nothing about or a wrapped integer and can only be used by passing the handle to library-provided functions.
We will execute the following steps to create an opaque handle type:
Create a private struct with no data members and no methods in the interface to represent the opaque type. If you are implementing the library, you may use members and methods internally, but do not expose them to the public interface.
Either use
alias Impl* Handle;
or create a public struct with only one data member—a pointer to the private struct or the handle ID if you use integers—to represent the handle. Mark this member private. The alias method works better when interfacing with C libraries that do not use a handle struct. Otherwise, the struct gives more control.Disable built-in functions on the public struct...