Hi,
How can we wrapp a c++ type that depends on a generic numerci parameter. For example, I tried this:
Vec* {.importcpp: "cv::Vec<\'0,\'1>", header: cv_core_path, bycopy.}[u_Tp;
cn: static[cint]] = object
The problem is that it generates:
cv::Vec<double,NI> v_XXXXX;
ie, the type of the generic parameter is used instead of its type. I tried with "'*1" instead of "'1" with the same result.
Is there a workaround ? I have the same problem with constructors that depends on a generic numeric parameter
Thanks
I'm pretty clueless here, but just some 2c.
How well is this handled in other non-C++ langs or tools which do have interop with C++?
Some examples that come to mind: D lang, Python with pybind11, and SWIG.
And a couple of other usual things - providing a C extern function from C++ that somehow gets the job done, or using the Nim "emit" statement at strategic places to get needed C++ interop code. Or reversing things - write the app mainly in C++, but take advantage of Nim lang as far as possible (eg, CPP codegen from Nim (or direct .so/dll files), which then gets pulled into the C++ compilation, but only where that works, and use native C++ for the rest - eg I'm reminded about how Chucklefish uses Rust for most of their code for Spellbound, but then uses console-specific code like C++ to call into the Rust logic).
It sounds like none of these would work (based on comments in this thread), but I'm mainly curious about why none of these are feasible :-)
@wizzardx I tried similar things to work around importing this templated C++ generic types bug
C extern function: Too much boilerplate code is needed on the C++ side and on the Nim side, "So you provided bindings for [T: SomeSignedInt] well now do [T:SomeInteger, N: static[int]] with N between 1 to 10" and suddenly instead of int, int32, int64 you have 10*{int, int32, int64} bindings to do.
I stopped quickly and I'm waiting for the bug.
Emit statement: I actually templated the C++ part of the boiler plate through Nim. I could have done the Nim part with macro as well but still this is a mess.
Writing in C++: "Spare me!" ;)