-
Notifications
You must be signed in to change notification settings - Fork 392
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
xclosure #85
xclosure #85
Conversation
08cb0b2
to
a158243
Compare
8e826d5
to
d983228
Compare
d983228
to
28360df
Compare
include/xtensor/xvectorize.hpp
Outdated
@@ -71,9 +66,10 @@ namespace xt | |||
|
|||
template <class F, class R> | |||
template <class... E> | |||
inline auto xvectorizer<F, R>::operator()(const E&... e) const -> get_xfunction_type<E...> | |||
inline auto xvectorizer<F, R>::operator()(E&&... e) const |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO: re-add -> get_xfunction_type?
Heads up to @wolfv since this is going to change how one writes ufuncs. |
28360df
to
e821e06
Compare
Thanks! |
The current mechanism may result in dangling references. Closure types are how expressions hold their different components (xfunction, xbroadcast). In In the old mechanism, when using an xfunction on an rvalue xarray (e.g built by a function), the closure type was always a const reference, the xfunction is then holding a const reference to a temporary, resulting in a dangling reference when composing it in another expression. The new mechanism is different. An expression built with a rvalue will hold a value, and move the rvalue to it. An expression built with an lvalue reference will hold a const reference to it. |
Thanks, good to know! I can also confirm that this PR is fixing the view iterator error I was constantly seeing 🎉 |
Cool, that is good to hear. |
@JohanMabille yay! |
Let's rock ! |
Ping @juanalday. You might be interested in this fix. #101 also somplifies this. |
@JohanMabille this also fixed the issue when replacing xscalar by 0-D xtensors or xarrays in the code base. So it is a good sanity check. |
For expressions:
For scalars:
This should solve #75.