本文介绍了从向量中取消引用ref类。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些非常简单的代码:

I have some pretty simple code:

int me = m_gridPos.y * m_gridWidth + m_gridPos.x; int mixPos = mixWith->m_gridPos.y * m_gridWidth + mixWith->m_gridPos.x;

(* m_grid)[mixPos] = this;
(* m_grid)[me] = mixWith;

(*m_grid)[mixPos] = this;(*m_grid)[me] = mixWith;

现在,网格只是指向包含块的向量的指针。 块类是一个ref类。

Now the grid is just a pointer to a vector with blocks in them.  The block class is a ref class.

std::vector<Block^>* m_grid;




但是,当我像上面那样取消引用网格时,会导致一些奇怪的异常变得非常复杂,并且有帮助吗?


But, when I dereference the grid like I do above, it causes some strange exceptions quite complicated, and help?

推荐答案

__declspec(non_user_code) __declspec(no_refcount) __declspec(no_release_return)
	inline void* __abi_winrt_ptr_assign(void** __ppTargetArg, const volatile ::Platform::Object^ __objArg)
{
	__abi_IUnknown* __pUnknown = reinterpret_cast<__abi_IUnknown*>(const_cast< ::Platform::Object^>(__objArg));
	__abi_IUnknown** __ppTargetUnknown = reinterpret_cast<__abi_IUnknown**>(__ppTargetArg);
	if (__pUnknown != *__ppTargetUnknown)
	{
		if (__pUnknown) {
			__pUnknown->__abi_AddRef();
		}
		if (*__ppTargetUnknown) {
			(*__ppTargetUnknown)->__abi_Release();
		}
		*__ppTargetUnknown = __pUnknown;
	}
	return __pUnknown;
}





这篇关于从向量中取消引用ref类。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 16:44