-
Notifications
You must be signed in to change notification settings - Fork 427
adding xt::detail::has_fixed_size and replacing is_array to expand supported types. #2556
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
base: master
Are you sure you want to change the base?
Conversation
1dd2a56 to
037ef36
Compare
|
The build only fails on the older msvc 19.0, but it's not clear why. It says |
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 error on Windows seems legit.
include/xtensor/xfixed.hpp
Outdated
| # pragma clang diagnostic ignored "-Wmismatched-tags" | ||
| #endif | ||
|
|
||
| namespace std |
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.
A good practice is to avoid opening std namespace. You can directly specialize tuple_size with the following syntax:
tempate <class ET, class S, xt::layout_type L, bool SH, class TAG>
struct std::tuple_size<xt::xfixed_container<ET, S, L, SH, Tag>> :
// ...Also pay attention that tuple_size is a struct, not a class (therefore, no need to specify a public inheritance, and this will avoid a lot of warnings).
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.
This specialization was done in the same style as here:
xtensor/include/xtensor/xstorage.hpp
Line 1915 in 3084585
| class tuple_size<xt::const_array<T, N>> : |
It also contains a comment about tuple_size being a class in c++ standard, I can just copy the comment here, or update also the xstorage version.
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.
My initial comment was based on the standard definition of tuple_size. However, it appears that th standard uses class tuple_size in other parts of the spec, and is therefore inconsistent. libc++ is consistent and uses class everywhere, so we can keep it. See this discussion for more detail about this issue.
The specializations in xstorage.hpp should be updated to avoid opening the std namespace, though.
037ef36 to
351378a
Compare
956e95f to
22a30c9
Compare
This pr adds type trait
xt::detail::has_fixed_sizeto replace a common usage ofxt::detail::is_arraywhere implementation can benefit if the size of the container (usually used for shape) is known at compile time. This allows to addxt::sequence_viewfor example to supported types for shape inxt::adapt, but even much much more.This also adds
xt::detail::get_fixed_shapeas a wrapper tostd::tuple_size. The reason this is needed is that for example forxfunctionthat has fixed shape, we also want to usestd::tuple_size, but we cannot partially specializestd::tuple_sizeonly for the cases whenxfunctionhas fixed shape.