C++;int向量到c# 我正在做一个C++项目,我想从C++的算法库中调用 NExtx置换>代码>。我发现了在C语言中调用C++函数的方法,但我不知道如何从C++中获得向量,并在C++中使用它(因为NExtx置换需要int向量…)< /P>
这就是我目前正在尝试的:C++;int向量到c# 我正在做一个C++项目,我想从C++的算法库中调用 NExtx置换>代码>。我发现了在C语言中调用C++函数的方法,但我不知道如何从C++中获得向量,并在C++中使用它(因为NExtx置换需要int向量…)< /P>,c#,c++,function,call,C#,C++,Function,Call,这就是我目前正在尝试的: extern void NextPermutation(vector<int>& permutation) { next_permutation (permutation.begin(),permutation.end()); } [DllImport("PEDLL.dll", CallingConvention = CallingConvention.Cdecl)] private static extern void
extern void NextPermutation(vector<int>& permutation)
{
next_permutation (permutation.begin(),permutation.end());
}
[DllImport("PEDLL.dll", CallingConvention = CallingConvention.Cdecl)]
private static extern void NextPermutation(IntPtr test);
extern void NextPermutation(向量和置换)
{
下一个置换(permutation.begin(),permutation.end());
}
[DllImport(“pedl.dll”,CallingConvention=CallingConvention.Cdecl)]
私有静态外部无效下一个术语(IntPtr测试);
实现这一点的唯一方法是通过C++/CLI包装类。但是,您必须将int[]或ListP/CUKEK对于C++类型是非常不利的。您应该尝试将问题简化为C接口。对你来说,这很容易
extern void NextPermutation(int *permutation, int count)
{
next_permutation (permutation, permutation + count);
}
你需要一些胶水来转换它。为什么不直接用C语言呢?谷歌给我这个: