mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-08-20 21:33:27 -07:00
Add constexpr to Sample class functions
This commit is contained in:
parent
c382191e75
commit
4a11fab2b1
1 changed files with 11 additions and 15 deletions
|
@ -38,34 +38,30 @@
|
||||||
template<typename T>
|
template<typename T>
|
||||||
struct Sample
|
struct Sample
|
||||||
{
|
{
|
||||||
Sample()
|
constexpr Sample() = default;
|
||||||
: download()
|
|
||||||
, upload()
|
constexpr Sample(const T dl, const T ul)
|
||||||
|
: download {dl}
|
||||||
|
, upload {ul}
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
Sample(T dl, T ul)
|
constexpr Sample<T> &operator+=(const Sample<T> &other)
|
||||||
: download(dl)
|
|
||||||
, upload(ul)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
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…
Add table
Add a link
Reference in a new issue