diff --git a/README.md b/README.md index 74a76af..14d6a7d 100644 --- a/README.md +++ b/README.md @@ -416,7 +416,14 @@ To write a C++ function that returns a new object that can be garbage-collected jlcxx::create(constructor_arg1, ...); ``` -This will return the new C++ object wrapped in a `jl_value_t*` that has a finalizer. +This will return the new C++ object wrapped in a `jl_value_t*` that has a +finalizer. The default constructor can be explicitly disabled by specializing +the `DefaultConstructible` type trait, for example: +```c++ +namespace jlcxx { + template<> struct DefaultConstructible : std::false_type { }; +} +``` ### Copy constructor @@ -427,6 +434,14 @@ wvec = cpp_function_returning_vector() julia_array = copy.(wvec) ``` +It can be explicitly disabled for a type by specializing the `CopyConstructible` +type trait, for example: +```c++ +namespace jlcxx { + template<> struct CopyConstructible : std::false_type { }; +} +``` + ### Return values If a wrapped C++ function returns an object by value, the wrapped object gets a finalizer and is owned by Julia. The same holds if a smart pointer such as `shared_ptr` (automatically @@ -802,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++