Add TimeDelta and Timestamp factories
These factories suppose to replace set of old constexpr factories that takes parameter as template rather than function parameter, as well as fix function naming to follow style guide of the second set of factory functions. Bug: None Change-Id: Icd76302b821b2a4027f9d6765cf91bc9190f551c Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/167521 Reviewed-by: Karl Wiberg <kwiberg@webrtc.org> Commit-Queue: Danil Chapovalov <danilchap@webrtc.org> Cr-Commit-Position: refs/heads/master@{#30482}
This commit is contained in:
committed by
Commit Bot
parent
3663f94143
commit
8d94dc23a6
@ -28,8 +28,26 @@ namespace webrtc {
|
||||
// difference of two Timestamps results in a TimeDelta.
|
||||
class Timestamp final : public rtc_units_impl::UnitBase<Timestamp> {
|
||||
public:
|
||||
template <typename T>
|
||||
static constexpr Timestamp Seconds(T value) {
|
||||
static_assert(std::is_arithmetic<T>::value, "");
|
||||
return FromFraction(1'000'000, value);
|
||||
}
|
||||
template <typename T>
|
||||
static constexpr Timestamp Millis(T value) {
|
||||
static_assert(std::is_arithmetic<T>::value, "");
|
||||
return FromFraction(1'000, value);
|
||||
}
|
||||
template <typename T>
|
||||
static constexpr Timestamp Micros(T value) {
|
||||
static_assert(std::is_arithmetic<T>::value, "");
|
||||
return FromValue(value);
|
||||
}
|
||||
|
||||
Timestamp() = delete;
|
||||
|
||||
// TODO(danilchap): Migrate all code to the 3 factories above and delete the
|
||||
// 6 factories below.
|
||||
template <int64_t seconds>
|
||||
static constexpr Timestamp Seconds() {
|
||||
return FromFraction(1'000'000, seconds);
|
||||
|
||||
Reference in New Issue
Block a user