Skip to content

Commit c7d6119

Browse files
committed
Document type and compile-time constants
1 parent a4eec02 commit c7d6119

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -832,6 +832,20 @@ mymodule.method("array", [] () {
832832
});
833833
```
834834

835+
## Type arguments
836+
837+
The C++ type `jlcxx::SingletonType` maps to the Julia `Type` parametric type (e.g. `jlcxx::SingletonType<double>` becomes `Type{Float64}`). This can be used to make C++ functions that dispatch on a type argument:
838+
839+
```c++
840+
mod.method("test_datatype_conversion", [] (jlcxx::SingletonType<double>) { return jl_float64_type; });
841+
```
842+
843+
Similarly, compile time constants can be wrapped using `jlcxx::Val`, which maps to Julia's `Val`type:
844+
845+
```c++
846+
mod.method("test_val", [](jlcxx::Val<int, 1>) { return 1; });
847+
```
848+
835849
## Calling Julia functions from C++
836850

837851
### Direct call to Julia

0 commit comments

Comments
 (0)