JuliaInterop / libcxxwrap-julia

C++ library for backing CxxWrap.jl
Other
84 stars 43 forks source link

Added support for Val{T} #123

Closed Keluaa closed 1 year ago

Keluaa commented 1 year ago

Added support for jlcxx::Val<T>, which works nearly identically as jlcxx::SingletonType<T>. All types supported by jlcxx::box should also work with Val<T>.

A separate specialization using std::string_view is used to support symbols too. Because C++ forbids strings of any kind in templates, we are forced to use a static constexpr const std::string_view to be able to use it as a template parameter. Since the type is a bit convoluted, I added the JLCXX_VAL_SYM macro to simplify the symbol declaration. Using a const char[] would have also been possible, but JLCXX_VAL_SYM would get a bit weirder to use, hence the std::string_view.

barche commented 1 year ago

Nice, thanks!