eschnett / CxxInterface.jl

Create Julia interfaces to C++ libraries
MIT License
45 stars 3 forks source link

Simple example #4

Open gitboy16 opened 2 years ago

gitboy16 commented 2 years ago

Hi, thank you for the package. Someone mentionned your package: https://discourse.julialang.org/t/ccall-c-sort-vector-of-string/74635/21

I was wondering if you would be able to provide a simple example (step by step) on how to sort a vector of strings using c++ std::sort. Thank you

eschnett commented 2 years ago

As described on Discourse, this question is somewhat ill-posed, i.e. there are details missing. Calling C++ requires handling many low-level details, and you still need to handle them when you call C++ from Julia. Such questions are:

If you are thinking of an existing C++ library, then looking at the library's API might help answer these questions.

If you are unfamiliar with the questions above, then some higher-level questions might help determine the answers:

gitboy16 commented 2 years ago

I'll try to answer your questions but if you need more information please let me know. -Julia creates/allocates the vectors -The vectors are passed to C++ for processing and then sent back to Julia for more processing. Once sent back to Julia, C++ does not need to keep these vectors. -The library handles std::vector<std::string> types only.

Thank you