インピーダンスの不整合は深刻です。ベクトルを作成できるように、C ++/CLI言語でラッパーを作成する必要があります。追加の問題はPointです。これに対するC++宣言は、その管理バージョンと互換性がありません。コードはこれに似ている必要があり、CLRノードからクラスライブラリプロジェクトに追加します。
#include <vector>
using namespace System;
using namespace System::Collections::Generic;
struct Point { int x; int y; };
void findNeighbors(Point p, std::vector<Point> &neighbors, double maxDist);
namespace Mumble {
public ref class Wrapper
{
public:
List<System::Drawing::Point>^ FindNeigbors(System::Drawing::Point p, double maxDist) {
std::vector<Point> neighbors;
Point point; point.x = p.X; point.y = p.Y;
findNeighbors(point, neighbors, maxDist);
List<System::Drawing::Point>^ retval = gcnew List<System::Drawing::Point>();
for (std::vector<Point>::iterator it = neighbors.begin(); it != neighbors.end(); ++it) {
retval->Add(System::Drawing::Point(it->x, it->y));
}
return retval;
}
};
}
コレクションをコピーするコストに注意してください。これにより、ネイティブC++でアルゴリズムを作成することで得られるパフォーマンスの利点がすぐに失われる可能性があります。