-
Notifications
You must be signed in to change notification settings - Fork 159
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
[onert] Simplify code using SFINAE technique #14715
base: master
Are you sure you want to change the base?
Conversation
This commit simplify code using the SFINAE technique. ONE-DCO-1.0-Signed-off-by: ragmani <[email protected]>
2de16fe
to
95600ac
Compare
typename = std::enable_if_t<std::is_base_of<Operation, OperationType>::value>> | ||
std::enable_if_t<std::is_base_of_v<Operation, OperationType>, bool> = true> |
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.
According to cppreference,
A common mistake is to declare two function templates that differ only in their default template arguments. This does not work because the declarations are treated as redeclarations of the same function template (default template arguments are not accounted for in function template equivalence).
it's better to use the explicit dummy parameter version (as in the "RIGHT" example). This ensures that the function signatures are distinct and avoids redefinition errors.
typename = std::enable_if_t<std::is_base_of<ILoweredGraph, LoweredGraphType>::value>> | ||
std::enable_if_t<std::is_base_of_v<ILoweredGraph, LoweredGraphType>, bool> = true> |
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.
ditto
template <typename T, typename U> | ||
typename std::enable_if<std::is_integral<T>::value && std::is_integral<U>::value, | ||
typename std::common_type<T, U>::type>::type | ||
ceil_div(T dividend, U divisor) | ||
template <typename T, typename U, | ||
std::enable_if_t<std::is_integral_v<T> && std::is_integral_v<U>, bool> = true> |
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.
ditto
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.
LGTM
{ | ||
assert(dividend > 0 && divisor > 0 && "this implementations is for positive numbers only"); | ||
assert(dividend > 0 && divisor > 0 && "this implementation is for positive numbers only"); |
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.
(minor)
Is it fine to include a fix that's not related?
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.
Maybe it's fine to me :) If you would like to separate it, I will do.
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.
LGTM
This commit simplify code using the SFINAE technique.
ONE-DCO-1.0-Signed-off-by: ragmani [email protected]