Browse Source

Add constexpr to Sample class functions

adaptive-webui-19844
Chocobo1 3 years ago
parent
commit
4a11fab2b1
No known key found for this signature in database
GPG Key ID: 210D9C873253A68C
  1. 24
      src/base/bittorrent/speedmonitor.h

24
src/base/bittorrent/speedmonitor.h

@ -38,34 +38,30 @@
template<typename T> template<typename T>
struct Sample struct Sample
{ {
Sample() constexpr Sample() = default;
: download()
, upload()
{
}
Sample(T dl, T ul) constexpr Sample(const T dl, const T ul)
: download(dl) : download {dl}
, upload(ul) , upload {ul}
{ {
} }
Sample<T> &operator+=(const Sample<T> &other) constexpr Sample<T> &operator+=(const Sample<T> &other)
{ {
download += other.download; download += other.download;
upload += other.upload; upload += other.upload;
return *this; return *this;
} }
Sample<T> &operator-=(const Sample<T> &other) constexpr Sample<T> &operator-=(const Sample<T> &other)
{ {
download -= other.download; download -= other.download;
upload -= other.upload; upload -= other.upload;
return *this; return *this;
} }
T download; T download {};
T upload; T upload {};
}; };
typedef Sample<qlonglong> SpeedSample; typedef Sample<qlonglong> SpeedSample;

Loading…
Cancel
Save