[RFC] improve readability of time literals #9299
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
We have various expressions like:
The number of 0's are hard to read, and we cannot use
8e6
, since this is of typedouble
.C++11 introduced user-defined literals, which allows to write the following:
As an example, I adjusted the land_detector to use the new literals. Commander would be a good candidate as well. We could also be more verbose if desired, for instance
8_sec
or even8_seconds
.I consider this as a start towards using more units throughout the code, for all the SI units we use, not only time. A potential library for this is https://github.com/nholthaus/units, as pointed out by @dagar . Some notes about it:
double
by default as underlying type, but it can be customized<chrono>
headerThoughts?
@MaEtUgR @RomanBapst @Stifael