http://eel.is/c++draft/time.duration#2
Rep
shall be an arithmetic type or a class emulating an arithmetic type.
http://eel.is/c++draft/time.duration#1
constexpr duration() = default;
Together these say that duration
is default-initialized as Rep
is default-initialized
http://eel.is/c++draft/dcl.init#7
To default-initialize an object of type T
means:
If T
is a (possibly cv-qualified) class type ([class]), constructors are considered. The applicable constructors are
enumerated ([over.match.ctor]), and the best one for the initializer
() is chosen through overload resolution ([over.match]). The
constructor thus selected is called, with an empty argument list, to
initialize the object. (7.2)
If T
is an array type, each element is default-initialized.
Otherwise, no initialization is performed.
Thus:
seconds s; // no initialization.
However, this:
seconds s{}; // zero-initialize
does value initialization, which for scalars is zero-initialization.
http://eel.is/c++draft/dcl.init#list-3.11
Otherwise, if the initializer list has no elements, the object is value-initialized.
http://eel.is/c++draft/dcl.init#8
To value-initialize an object of type T means:
- if T is a (possibly cv-qualified) class type ([class]), then ...
- otherwise, the object is zero-initialized.
http://eel.is/c++draft/dcl.init#6
To zero-initialize an object or reference of type T means:
- if T is a scalar type, the object is initialized to the value obtained by converting the integer literal 0 (zero) to T;90
So duration
clients have their choice of either uninitialized or zero-initialized, with the std-supplied duration
s which are guaranteed to have a signed integral Rep
. If you use a custom duration with a class type Rep
, then it will be default-initialized by whatever definition that Rep
follows.