Makes all units and operations constexpr

Since RTC_DCHECK was made constexpr compatible, we can now
make the unit classes fully constexpr.

Bug: webrtc:9883
Change-Id: I18973c2f318449869cf0bd45699c41be53fba806
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/167722
Commit-Queue: Sebastian Jansson <srte@webrtc.org>
Reviewed-by: Ali Tofigh <alito@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#30403}
This commit is contained in:
Sebastian Jansson
2020-01-29 10:44:51 +01:00
committed by Commit Bot
parent 48be482d73
commit d7fade5738
8 changed files with 79 additions and 65 deletions

View File

@ -32,12 +32,12 @@ class DataSize final : public rtc_units_impl::RelativeUnit<DataSize> {
}
template <typename T>
static DataSize bytes(T bytes) {
static constexpr DataSize bytes(T bytes) {
static_assert(std::is_arithmetic<T>::value, "");
return FromValue(bytes);
}
template <typename T = int64_t>
T bytes() const {
constexpr T bytes() const {
return ToValue<T>();
}