-
Notifications
You must be signed in to change notification settings - Fork 586
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 mapping for std::chrono
#766
Conversation
On Linux, with option 1, |
A fourth option is to keep template instantiations low and add pure java helper functions using generics or inheritance to improve the API. |
No, let's keep this as close as possible to the C++ API. |
We can always add those at a later point in time right? It won't change the current code in this PR? |
It will just add more java mappings. |
Please add a dummy src/main/java/org/bytedeco/javacpp/presets/chrono.java with |
Done, but:
|
Right, we probably need to add a dummy global.chrono.class that extends from presets.chrono.class and make the other classes inherit from that. I guess we could do a jnichrono, but let's get the basics working first |
That's committed, and seems to work, but I didn't make the dummy global class extending the presets class |
I added the property inheritance of chrono classes towards chrono presets, and chrono presets towards javacpp presets. |
So, does it work like that with |
With info maps added in last commit, yes. |
That's a bit weird, I don't know where that would be needed. Anyway, I guess that's OK as a workaround. What happens if we do |
When the headers of a client presets like pytorch are parsed, if a
Not tested but should work. Class inheriting would have a |
Sounds good, let's just rename the global class to global.chrono though |
So, this is only available since C++11, so do we want to make JavaCPP depend on C++11 🤔 I guess it's as a good time as any to do it... If that's the case, then let's also just use char16_t to fix #753 |
That or a separate presets. |
Nah, let's leave more complicated stuff for another time. And let's just make C++11 the minimum requirement, feels fine to me at this point in time. |
Add support for the standard chrono library, sticking to C++11 (not the additions of C++20).
std::chrono
makes heavy uses of templates.This PR add mapping for the classical integral durations, and 2 floating point durations.
Concerning the instantiation of function and operator templates (mathematical operations, comparisons...), we have 3 options:
s
and a duration in hoursh
, users will have to do:or:
Or rather:
This needs about 7 Java methods per templated function/operator.
or:
This needs about 28 Java methods per binary templated function/operator.