Open eschnett opened 3 years ago
It looks as if this was a bit more complicated. You need also a new C++ class DictRef<K,T>
, which wraps a Julia dictionary, so that they can be accessed for C++ with an API similar to std::map<K,T>
. See the file array.hpp
that implements ArrayRef<T>
for Julia's Vector
type.
Given that this has been dormant for such a long time, I guess I shouldn't be too hopeful that there has been any progress yet? @eschnett did you ever succeed in creating a wrapper (perhaps only locally)?
@barche I tried to come up with a PR to libcxxwrap-julia by following the suggestions in https://github.com/JuliaInterop/CxxWrap.jl/issues/190#issuecomment-579455100. However, I got stuck very early since all existing STL types only support one template argument, which prevents me from using the smart-copy-and-extend-existing-code approach. It's probably too much to ask, but is there any chance you might be willing to step in here?
@sloede Unfortunately I did not.
@sloede How many different std::map
key types do you need? In my experience the key is usually either int
or std::string
, and thus implementing two versions that have one template parameter might work.
In my experience the key is usually either
int
orstd::string
, and thus implementing two versions that have one template parameter might work.
That is very true. OTOH, I feel like it wouldn't do a very good service to most users if we only had a "half-solution" here, which works only for a very limited subset of cases.
I saw what you did with std::pair
here, so I think I might mimic this in my code where I need std::map
. Has this worked for you so far for pairs?
How difficult would it be to add support for
std::map
as anAbstractDict
in Julia?I've browsed the source code, and it seems that implementing this along the lines in which
std::vector
is handled seems straightforward. The only complication I'm seeing is thatstd::map
takes two template arguments, not just one.As far as I can tell, implementing this would touch three files:
stl.hpp
andstl.cpp
inlibcxxwrap-julia
, as well as the fileStdLib.jl
inCxxWrap
.Would this be feasible? Am I missing something?