UE4【C++】【UE4实现形参为Function的模板函数】

//A.cpp
template
void ForEachPart(Functor functor)
{
	for (unsigned int z = 0, zSize = Parts.getHeight(); z < zSize; ++z)
	{
		for (unsigned int y = 0, ySize = Parts.getWidth(); y < ySize; ++y)
		{
			for (unsigned int x = 0, xSize = Parts.getLength(); x < xSize; ++x)
			{
				functor(Parts[x][y][z].ptr);
			}
		}
	}
}
A* Parts;
Parts->ForEachPart([](B* part)
{
	part->Destroy();
});

 

你可能感兴趣的:(UE4)