Constructors
Synopses
Declared in <bsls_timeinterval.h>
Create a time interval having the value of 0 seconds and 0 nanoseconds.
constexpr
TimeInterval();
Create a time interval having the value represented by the specified real number of seconds. The fractional part of seconds, if any, is rounded to the nearest whole number of nanoseconds. The behavior is undefined unless the total number of seconds in the resulting time interval can be represented with a 64‐bit signed integer.
explicit
TimeInterval(double seconds);
Create a time interval having the value given by the sum of the specified integral number of seconds and nanoseconds. The behavior is undefined unless the total number of seconds in the resulting time interval can be represented with a 64‐bit signed integer (see isValid). Note that there is no restriction on the sign or magnitude of either argument except that they must not violate the method's preconditions.
constexpr
TimeInterval(
bsls::Types::Int64 seconds,
int nanoseconds);
Create a time interval having the value represented by the specified duration when the conversion requires an explicit constructor. See the implicit overload for additional details on behavior and preconditions.
template<
class REP_TYPE,
class PERIOD_TYPE>
constexpr
explicit
TimeInterval(
std::chrono::duration<REP_TYPE, PERIOD_TYPE> const& duration,
int* = 0)
requires TimeInterval_DurationTraits<
REP_TYPE,
PERIOD_TYPE>::k_EXPLICIT_CONVERSION_ENABLED;
Create a time interval having the value represented by the specified duration. Only integer representations of duration are supported (i.e. REP_TYPE is integer). If the duration can be represented exactly by an integer nanoseconds this constructor will be implicit. Otherwise, the constructor will be explicit. The behavior is undefined unless the duration can be converted to a valid TimeInterval object, whose seconds field may have any 64‐bit signed integer value and nanoseconds field limited to the range [ ‐999,999,999..999,999,999 ]. Note that the current implementation of the lossy conversions (e.g., fractions of a nanosecond) truncates the values towards zero, however this behavior may change without notice in the future, so do not rely on this.
template<
class REP_TYPE,
class PERIOD_TYPE>
constexpr
TimeInterval(
std::chrono::duration<REP_TYPE, PERIOD_TYPE> const& duration,
int* = 0)
requires TimeInterval_DurationTraits<
REP_TYPE,
PERIOD_TYPE>::k_IMPLICIT_CONVERSION_ENABLED;
Created with MrDocs