hxcpp
hxcpp copied to clipboard
Feature request. Generics for externs
It is currently possible to use std::vector (in a little bit complicated way), but no ways to use std::array (or I just don't know how).
So would be nice to have something like:
@:native('std::array<T, S>') // I think it is hard to put something like this,
@:native('std::array<{0}, {1}>', T, S) // so maybe it may be as this?
@:native('std::array') // or like this and T and S will be atomatically added as template values
extern class StdArray<T, @:const S> {
...
}
//and somewhere in code:
var arr:StdArray<Int, 10> = ....;
This may help a lot to work with C++ templates in Haxe.
I need a solution like this too! I am stuck!!
This is partially supported now since haxe 4.3.0: https://github.com/HaxeFoundation/haxe/pull/10415 (you'd use @:native('std::array'))
However, there is dodgy code generation when using the constant value template:
Error: ./src/Main.cpp:5:10: fatal error: I10.h: No such file or directory
5 | #include <I10.h>
std::array< int, ::I10 > a = std::array< int, ::I10 >();