JuliaInterop / Cxx.jl

The Julia C++ Interface
Other
755 stars 107 forks source link

How to wrap templated C++ class with Cxx #479

Open TomasOberhuber opened 4 years ago

TomasOberhuber commented 4 years ago

Hi again,

I am trying to export interface of C++ templated library to Julia using Cxx and I cannot find a good way how to do it. Suppose I have a class like this:

template< typename T >
struct myArray
{
   myArray() {...};

   myArray( int size ) {...};

  void setSize( int size ) {...};

   int getSize() {...};
};

I would like to use Cxx in Julia to define struct, constructor with size and functions getSize and setSize. And another question, how could I deal with type T? How to pass it from Julia to myArray?

Thanks for ant help, Tomas.

Gnimuc commented 4 years ago

You might be interested in this example: https://github.com/JuliaInterop/Cxx.jl/blob/1c1b72b900606cee4909f068984d2f630130f720/src/std.jl#L14

TomasOberhuber commented 4 years ago

Perfect, it looks great. Thanks a lot.