Alex Afanasyev wrote:
I disagree with this. Time duration is not a typedef, but a non-trivial type. Even though it may be just a number underneath, it is non-obvious.
Actually, the ISO C++ standard requires the object representation of chrono::duration to be "an arithmetic type or a class emulating an arithmetic type". So yes, storage-wise it has to be an integral or floating point number of some kind. Plus its constructors must be constexpr.
When I said "convenience typedefs" I was referring to chrono::seconds, chrono::milliseconds, and so on... which are typedefs (again, see the standard).
Moreover, C++14 introduced literal suffixes for them, so they are supposed to be used like literals.
I would strongly object changing existing code, I would mind using either for the new code.
I don't want to change existing code "en masse" either... I actually opened this ticket because Junxiao refused to change from "const&" to "by-value" during code review.
But can we all agree that future code is strongly encouraged to pass these types by value? :) Saying that you don't mind "using either" is like saying that you're ok with code like void foo(const int& x);... which honestly hurts my eyes. So please reconsider.