1

I could not find any useful documentation about marshaling List List List of tuples, into Vector Vector Vector of pairs. I wrote some code, but i could not use it because it uses generics, is there any way to send data to C++ dll library and return them, using maybe references?

//C#
List<List<List<Tuple<SomeClassWithFloats, SomeClassWithFloats>>>> someTupleData = new List<List<List<Tuple<SomeClassWithFloats, SomeClassWithFloats>>>>();
SomeFunction(someTupleData, dataIntPtr);
//C++
extern "C" SOME_API void SomeFunction(const std::vector<std::vector<std::vector<std::pair<SomeClassWithFloats, SomeClassWithFloats>> > > & vertices, SomeStructWithVectors* data);
SolarCore
  • 133
  • 2
  • 16
  • 2
    Unfortunately you won't be able to use any templated objects like `std::vector`; you need a C-compatible interface. Then you could find a way to wrap it into what you wrote here. But C# won't be able to marshal directly to it like that. (see also: https://stackoverflow.com/a/4551798/402169) – tenfour Mar 30 '20 at 10:13
  • 1
    You need a C++ compiler to understand an std::vector object. That [is possible](https://stackoverflow.com/questions/6146701/what-is-the-most-efficient-way-to-convert-a-stdvectort-to-a-net-listu). – Hans Passant Mar 30 '20 at 11:27

0 Answers0