JuliaInterop / libcxxwrap-julia

C++ library for backing CxxWrap.jl
Other
84 stars 43 forks source link

Implement postfix++/-- in array_iterator_base #59

Closed rgcv closed 4 years ago

rgcv commented 4 years ago

Took the liberty of submitting a PR aiming to complement / fix #58 using the patch described in said issue.

Usage of auto can be dropped in favor of explicit typing, if preferrable. Just felt like avoiding redundancy.

rgcv commented 4 years ago

Woops, bit of a jumble, mishap closure.

jstrube commented 4 years ago

I'm not a maintainer, just a casual user, but I wonder if you could add a test for this new functionality.

rgcv commented 4 years ago

I'm not a maintainer, just a casual user, but I wonder if you could add a test for this new functionality.

Same here, we're in the same boat.

You know, I thought about it at the time. Just didn't quite know how to go about it. Not only am I not confident enough to meddle too much in outside code (this instance is exceptional), but I'm not also sure of what a simple, nearly atomic, example test case for this would be. Maybe a simple int array where every element is incremented. Something like:

// c++
mod.method("postinc!", [](jlcxx::ArrayRef<int> is) {
  auto it = is.begin();
  while (it != is.end()) *it++ += 1;
  return is;
});
# julia
@test all(postinc!([1,2,3]) .== [2,3,4])