2 ms·
AFAICT, D requires the C++ types be exported, included any predefined template objects or functions. E.g. you can’t dynamically wrap `std::map<K,V>`, unless it’
by elcritch 7y ago
AFAICT, D requires the C++ types be exported, included any predefined template objects or functions. E.g. you can’t dynamically wrap `std::map<K,V>`, unless it’s already been instantiated in C++ library you’re linking. The same in Rust as well. See D Lang manual:
Note that all instantiations used in D code must be provided by linking to C++ object code or shared libraries containing the instantiations.
Whereas Nim is one of the few languageS that can dynamically wrap C++ template types into its type system. Maybe Zig can do it too? See Nim manual [2].
type StdMap {.importcpp: "std::map", header: "<map>".}[K, V] = object proc
...
var x: StdMap[cint, cdouble]
x[6] = 91.4
...
std::map<int, double> x;
x[6] = 91.4;
This makes it nice to wrap C++ libraries. :-)
1: https://dlang.org/spec/cpp_interface.html#cpp-templates https://dlang.org/spec/cpp_interface.html#cpp-templates
2: https://nim-lang.org/docs/manual.html#importcpp-pragma-importcpp-for-objects https://nim-lang.org/docs/manual.html#importcpp-pragma-impor...