-
Notifications
You must be signed in to change notification settings - Fork 402
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
add xexpression_shaped experiment #867
Conversation
This looks nice! One (naïve) question: would it be possible to put |
@benbovy it depends, the way it is done now ensures this works for arrays, tensors and views. We could move the |
OK, I see. I now better understand what is supported / not supported when we use I was actually hesitating on which to choose in my function signatures. Inside these functions I use most of the time the container methods as the algorithms I'd like to implement are not easy to write using basic expressions. But sometimes I need to use views. So I think I'm gonna stick with |
You can use method with explicit signatures in your APIs and then forward to private methods accepting anything, so the derived cast would be done a few times only: namespace detail
{
template <class E>
auto f_impl(E&& e)
{
// here you can use e(0, 0, ...), e.shape(), and even e+= something
return something;
}
}
template <class E>
auto f(const xexpression_shape<E>& e)
{
return detail::f_impl(e.derived_cast());
} This way you can also use the same implementation for rvalue references if you want to support them too: template <class E>
auto f(xexpression<E>&& e)
{
return detail::f_impl(std::move(e.derived_cast()));
} |
Thanks for the tip @JohanMabille. |
56e8fe3
to
5e65bf9
Compare
superseded by #994 |
This will most likely fail on travis etc. but this could be a way to add the feature of #860 ?
this allows for overloads like this:
we could also add some shorthand forms for
xexpression_shaped<T, S>
likextensor_t<...>
etc.