-
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
Eye function #80
Eye function #80
Conversation
Sorry for responding so late, I was very busy these last days. I think we should avoid using Besides, you can't "fix" the iterator's type to be used since the function can be called from So it's nice you replaced the I don't understand the compilation error on Windows yet, but I'm on it. |
Good to hear! :) |
It seems xtensor somehow breaks Another remark would be to make |
About the Windows compilation issue: The problem comes from template <template <class...> class F, class... E>
template <template <class...> class F, class... E>
using get_xfunction_type = std::enable_if_t<has_xexpression<E...>::value,
xfunction<F<common_value_type<E...>>,
common_value_type<E...>,
get_xexpression_type<E>...>>; The problem is Visual Studio evaluates the second argument of |
@@ -135,7 +135,7 @@ namespace xt | |||
} | |||
}; | |||
|
|||
template <class T, template<class, class> class F> | |||
template <class T, template <class> class K, class F = K<T>> |
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.
I don't understand why you use a third template parameter with a default value set to K<T>
. It seems you don't use the K
parameter elsewhere in this class, so maybe you could just do something like:
template <class T, template <class> class F>
class fn_impl
{
using functor_type = F<T>;
....
};
Or, even better, add a value_type
typedef in eye_fn
, and retrieve it in fn_impl
. This way you don't need the T
template parameter.
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.
The best solution would be to deduce the value type from any callable type (including lambda), but that requires more work. This can be done after this feature has been integrated, though. Let me know which option you prefer.
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.
I changed things a bit more to accommodate for the k
parameter. Let me know what you think.
Perfect ! |
Hi,
I've implemented the eye function through xgenerator. This time I tried to use a generic std::function that works on iterators.
However, I faced a difficulty when using the static array + std::begin/end() combination @SylvainCorlay demonstrated in the last PR. I didn't find any way to keep the std::function as a function template.
Do you have ideas / is it necessary?
I think if this works well, the fn_impl could get some nice helper-wrapper to initialize a xgenerator from a lambda function, or the mechanism could be integrated directly into xgenerator.