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
@ -32,7 +32,26 @@ namespace webrtc {
|
||||
// microseconds (us).
|
||||
class TimeDelta final : public rtc_units_impl::RelativeUnit<TimeDelta> {
|
||||
public:
|
||||
template <typename T>
|
||||
static constexpr TimeDelta Seconds(T value) {
|
||||
static_assert(std::is_arithmetic<T>::value, "");
|
||||
return FromFraction(1'000'000, value);
|
||||
}
|
||||
template <typename T>
|
||||
static constexpr TimeDelta Millis(T value) {
|
||||
static_assert(std::is_arithmetic<T>::value, "");
|
||||
return FromFraction(1'000, value);
|
||||
}
|
||||
template <typename T>
|
||||
static constexpr TimeDelta Micros(T value) {
|
||||
static_assert(std::is_arithmetic<T>::value, "");
|
||||
return FromValue(value);
|
||||
}
|
||||
|
||||
TimeDelta() = delete;
|
||||
|
||||
// TODO(danilchap): Migrate all code to the 3 factories above and delete the
|
||||
// 6 factories below.
|
||||
template <int64_t seconds>
|
||||
static constexpr TimeDelta Seconds() {
|
||||
return FromFraction(1'000'000, seconds);
|
||||
|
||||
Reference in New Issue
Block a user