-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Extend tuple features (e.g. join) to tuple-like objects #4226
Comments
Thanks for the suggestion. I think it's reasonable to add tuple-like object support to |
Does it work? I think godbolt has updated, but the library still fails for a tuple-like structure: |
https://en.cppreference.com/w/cpp/utility/tuple_size template<class... Ts>
struct std::tuple_size<boost::multi::detail::tuple<Ts...>> { // NOLINT(cert-dcl58-cpp) to have structured bindings
// cppcheck-suppress unusedStructMember
static constexpr std::size_t value = sizeof...(Ts);
}; does not inherit |
Good point, I didn't know that the type has to specifically inherit from |
Adding a |
Yes, the whole reimplementation of tuple was a hack to make the code work on CUDA. In perspective, maybe this is because of the problem you noticed, about inheriting from |
@phprus I think getting into the namespace std was there to be able to access elements using the full syntax
EDIT: regarding 1), I now remember the problem, in C++17, when I tried to use the ADL |
|
Yes, I agree. I now modified the code to not need the specialization std::get (the ADL and members were in place already). Tomorrow I will try again with fmt to see if it works. |
It works now! https://godbolt.org/z/Mdo8YYqnf fmt::print("{} ", fmt::join(arr.sizes(), "×")); // prints 2×2
fmt::print("{}\n", fmt::join(arr, "\n"));
\\ prints
\\ [3, 4]
\\ [6, 7] |
A 2D array can be seen as a container of container (range of ranges), so I wonder if one can control the formatting of the nested ranges. Since this is close to supporting formatting "tables" (but not exactly), I wonder if controlling the format of nested ranges is within the scope of the library: https://stackoverflow.com/questions/79193937/control-fmt-formatting-of-nested-containers-ranges |
Discussed in #4240 |
For some technical reasons I had to replicate the functionality of std::tuple in my library. (see here: https://github.com/correaa/boost-multi?tab=readme-ov-file#formatting-fmt-pretty-printing)
I would be nice that the features in fmt would work on any type that has
std::get<N>
,std::tuple_size
, etc. in their interface.That is, if a type is tuple like then it could be printed as a tuple.
(This will also work on any class for which structured binding is implemented).
Here it is a godbolt example:
https://godbolt.org/z/Gof6f4oaE
The text was updated successfully, but these errors were encountered: