You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First of all, thank you for bringing such a wonderful library, and I am very happy that C++20 has finally adopted it.
I would like to know why the corresponding literal operator was not introduced when the duration aliases such as day/weeks/months/years were introduced because the duration aliases such as seconds that come with <chrono> have their corresponding literal operators.
I personally found it valuable to add a literals operator with the same name for them, which allows us to express the code more intuitively:
auto m = October;
m += 8months;
auto y = 2004y + 300years;
auto d = 100d += 20days;
auto w = Sunday;
w += 2weeks;
So I wonder why they weren't introduced in the first place, is it because the names are too long? Or is there a specific reason?
Is it worth it or is it superfluous? I'd like to know your thoughts on this.
Thanks,
Hewill
The text was updated successfully, but these errors were encountered:
Thanks for your kind words. I'm glad you found this library useful.
I think "superfluous" is probably the best description of my thought process. For me a literal is a more concise way of reading and writing a unit such as s or y. However when the whole type is spelled out in the literal name, the literal for becomes only two characters shorter:
m += months{8};
vs
m += 8months;
so it just didn't seem worth it to add the complication of two ways to write the same thing.
I struggled more with where to place the y and d literals: with the durations years and days or the calendrical specifiers year and day. I chose the calendrical specifiers from a hunch that they would end up appearing in code more often than the durations. I.e. with date literals such as:
Hi Howard,
First of all, thank you for bringing such a wonderful library, and I am very happy that C++20 has finally adopted it.
I would like to know why the corresponding literal operator was not introduced when the
duration
aliases such asday/weeks/months/years
were introduced because the duration aliases such as seconds that come with<chrono>
have their corresponding literal operators.I personally found it valuable to add a literals operator with the same name for them, which allows us to express the code more intuitively:
So I wonder why they weren't introduced in the first place, is it because the names are too long? Or is there a specific reason?
Is it worth it or is it superfluous? I'd like to know your thoughts on this.
Thanks,
Hewill
The text was updated successfully, but these errors were encountered: