C++ 如何通过C++;lambda函数到另一个函数?

C++ 如何通过C++;lambda函数到另一个函数?,c++,closures,C++,Closures,召唤 auto xxx= [&radius](Vector3 pos)->float { SDF sdf; return sdf.Sphere(Vector3(pos.X, pos.Y, pos.Z), radius); }; 在 它说,…没有合适的转换函数… 当我从lambda中删除引用(闭包)时,它不会给出错误。请参阅。用,所以用。在下一个问题中提供一些,只有没有捕获的lambda才能转换为函数请参见ClosureType::opera

召唤

auto xxx= [&radius](Vector3 pos)->float {
        SDF sdf;
        return sdf.Sphere(Vector3(pos.X, pos.Y, pos.Z), radius);
    };

它说,
…没有合适的转换函数…


当我从lambda中删除引用(闭包)时,它不会给出错误。

请参阅。用,所以用。在下一个问题中提供一些,只有没有捕获的lambda才能转换为函数请参见ClosureType::operator ret(*)(params)()这里还有一点小问题,即创建悬挂引用。@RichardCriten“
&radius
创建悬挂引用*”-仅当
xxx
radius
超出范围后使用,我们无法从这个有限的片段中确定。
DensityPoint*** densityPoints2 = GetDensityData(dimensions, Vector3(), Vector3(), xxx);
DensityPoint*** Density::GetDensityData(Vector3 dimensions, Vector3 fractions, Vector3 offsets, float f(Vector3 pos))
{