Magnum::Math::Literals::TimeLiterals namespace new in Git master

Math time literals.

See the Literals namespace and the Nanoseconds and Seconds classes for more information.

Functions

auto operator""_nsec(unsigned long long value) -> Nanoseconds<Long> constexpr new in Git master
Nanosecond value literal.
auto operator""_usec(long double value) -> Nanoseconds<Long> constexpr new in Git master
Microsecond value literal.
auto operator""_msec(long double value) -> Nanoseconds<Long> constexpr new in Git master
Millisecond value literal.
auto operator""_sec(long double value) -> Nanoseconds<Long> constexpr new in Git master
Second value literal.

Function documentation

Nanoseconds<Long> Magnum::Math::Literals::TimeLiterals::operator""_nsec(unsigned long long value) constexpr new in Git master

Nanosecond value literal.

Compared to the microsecond, millisecond and second literals, this literal is an integer value and not a floating-point, as it's not possible to represent fractions of nanoseconds. Usage example:

using namespace Math::Literals;

Nanoseconds twoSeconds = 2000000000_nsec;

Nanoseconds<Long> Magnum::Math::Literals::TimeLiterals::operator""_usec(long double value) constexpr new in Git master

Microsecond value literal.

As the value is converted to whole nanoseconds, everything after thousandths is truncated. Additionally, up to thousandths the conversion is without precision loss only on systems with a 80-bit long double (which has a 63-bit mantissa). If you need to ensure nanosecond-level precision on systems that have a 64-bit long double, use operator""_nsec() instead. On the other hand, if nanosecond-level precision isn't needed, it's possible to convert directly to Seconds that offer a microsecond-level precision on a range of roughly ±8 seconds. For example:

using namespace Math::Literals;

Nanoseconds a = 2000000.0_usec;
Seconds b = 2000000.0_usec;

Nanoseconds<Long> Magnum::Math::Literals::TimeLiterals::operator""_msec(long double value) constexpr new in Git master

Millisecond value literal.

As the value is converted to whole nanoseconds, everything after millionths is truncated. Additionally, up to millionths the conversion is without precision loss only on systems with a 80-bit long double (which has a 63-bit mantissa). If you need to ensure nanosecond-level precision on systems that have a 64-bit long double, use operator""_nsec() instead. On the other hand, if nanosecond-level precision isn't needed, it's possible to convert directly to Seconds that offer a millisecond-level precision on a range of roughly ±2 hours. For example:

using namespace Math::Literals;

Nanoseconds a = 16.67_msec;
Seconds b = 16.67_msec;

Nanoseconds<Long> Magnum::Math::Literals::TimeLiterals::operator""_sec(long double value) constexpr new in Git master

Second value literal.

As the value is converted to whole nanoseconds, everything after billionths is truncated. Additionally, up to billionths the conversion is without precision loss only on systems with a 80-bit long double (which has a 63-bit mantissa). If you need to ensure nanosecond-level precision on systems that have a 64-bit long double, use operator""_nsec() instead. On the other hand, if nanosecond-level precision isn't needed, it's possible to convert directly to Seconds that offer a millisecond-level precision on a range of roughly ±2 hours. For example:

using namespace Math::Literals;

Nanoseconds a = 45.0_sec;
Seconds b = 45.0_sec;