0 is natural default value for types that can be accumulated
Having default constructor simplify usage of these types in templated code.
Bug: None
Change-Id: If005c69018a2a11011bc789502fdbc600cad3278
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/369440
Reviewed-by: Per Kjellander <perkj@webrtc.org>
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Commit-Queue: Per Kjellander <perkj@webrtc.org>
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#43460}
This is quite useful in many places where we need to restrict the range
of a DataRate. It makes it easier to read the intention than with:
value_ = std::max(some_lower_limit, std::min(value_, some_upper_limit));
The naming follows the naming for rtc::SafeClamp.
Bug: webrtc:9709
Change-Id: I08e05197acec325d85babd2a06806a8667f2fcb1
Reviewed-on: https://webrtc-review.googlesource.com/c/104040
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Commit-Queue: Sebastian Jansson <srte@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#25023}
This adds new constexpr create function for DataSize, DataRate,
TimeDelta and Timestamp. The names are capitalized to mirror the
naming scheme of the previously constexpr methods (Zero and
Infinity create functions). They are also kept longer since they
are not expected to be used in complex expressions.
Bug: webrtc:9574
Change-Id: I5950548718675050fc5d66699de295455c310861
Reviewed-on: https://webrtc-review.googlesource.com/91161
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Commit-Queue: Sebastian Jansson <srte@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#24218}
This makes the constructor and the unchecked create functions
constexpr on the unit classes Timestamp, TimeDelta, Datarate and
DataSize. This allows using the units in constexpr constants.
Unchecked access methods are made constexpr as well. Making them
usable in static asserts.
Constexpr create functions for checked construction is added in
a separate CL.
Bug: webrtc:9574
Change-Id: I605ae2e8572195dbb2078c283056208be0f43333
Reviewed-on: https://webrtc-review.googlesource.com/91160
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Commit-Queue: Sebastian Jansson <srte@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#24206}
The behavior of division-by-zero is undefined, so the DivisionByZeroFails test isn't correct. As we don't need any specific behavior on division-by-zero we leave the current code untouched.
Additionally, since the DivisionFailsOnLargeSize EXPECT_DEATH checks rely on DCHECKs, we only run those when DCHECKs are enabled.
Bug: webrtc:9443
Change-Id: I0fdd7be55a7bc76b4203b2f6d5cd0ed8ac5cc688
Reviewed-on: https://webrtc-review.googlesource.com/85362
Commit-Queue: Jonas Olsson <jonasolsson@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23767}
This prepares for being able to inject network congestion controllers.
And makes it easier to use the units in other parts of the code.
Bug: webrtc:9155
Change-Id: Ib8f9c1c97b06d791a01c3376046933d576ae46f9
Reviewed-on: https://webrtc-review.googlesource.com/70201
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Commit-Queue: Sebastian Jansson <srte@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23168}
2018-05-08 11:46:22 +00:00
Renamed from modules/congestion_controller/network_control/units/data_rate_unittest.cc (Browse further)