From 9b23b7f439de096811c69f2d4c0086837f29e2cb Mon Sep 17 00:00:00 2001 From: JamesWrigley Date: Wed, 19 Jun 2024 13:08:51 +0200 Subject: [PATCH] Document jlcxx::Array --- README.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/README.md b/README.md index 8b103fd..14d6a7d 100644 --- a/README.md +++ b/README.md @@ -817,6 +817,20 @@ An extra file has to be included to have constant array functionality: `#include Replacing `make_const_array` in the examples above by `make_julia_array` creates a mutable, regular Julia array with memory owned by C++. +### Returning a Julia array + +A Julia-owned `Array` can be created and returned from C++ using the +`jlcxx::Array` class: +```c++ +mymodule.method("array", [] () { + jlcxx::Array data{ }; + data.push_back(1); + data.push_back(2); + data.push_back(3); + + return data; +}); +``` ## Calling Julia functions from C++