有没有使用以下的替代方法?
class IGraphBuilder;
public ref class Device
{
private:
IGraphBuilder* pGraphBuilder;
public:
void Configure()
{
pin_ptr<IGraphBuilder*> ppGraphBuilder = &pGraphBuilder;
HRESULT hr = CoCreateInstance(CLSID_FilterGraph,
NULL,
CLSCTX_INPROC,
IID_IGraphBuilder, (void**)ppGraphBuilder);
reinterpret_cast(ppGraphBuilder) 编译,但如果这对于这种情况是正确的,我有点困惑。
如果这不是 C++/CLI(&NativeMember
实际上是指interior_ptr<Type>(NativeMember)
),我会简单地使用static_cast<void**>(&pGraphBuilder)
,但即使正确转换为pin_ptr
以下内容也无法编译
pin_ptr<IGraphBuilder*> ppGraphBuilder = &pGraphBuilder;
static_cast<void**>(ppGraphBuilder)
有什么解决方案还是我被迫使用 (void**) 因为 pin_ptr 很奇怪?