mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-24 05:25:37 +00:00
Add constexpr to Sample class functions
This commit is contained in:
parent
c382191e75
commit
4a11fab2b1
@ -38,34 +38,30 @@
|
||||
template<typename T>
|
||||
struct Sample
|
||||
{
|
||||
Sample()
|
||||
: download()
|
||||
, upload()
|
||||
constexpr Sample() = default;
|
||||
|
||||
constexpr Sample(const T dl, const T ul)
|
||||
: download {dl}
|
||||
, upload {ul}
|
||||
{
|
||||
}
|
||||
|
||||
Sample(T dl, T ul)
|
||||
: download(dl)
|
||||
, upload(ul)
|
||||
{
|
||||
}
|
||||
|
||||
Sample<T> &operator+=(const Sample<T> &other)
|
||||
constexpr Sample<T> &operator+=(const Sample<T> &other)
|
||||
{
|
||||
download += other.download;
|
||||
upload += other.upload;
|
||||
upload += other.upload;
|
||||
return *this;
|
||||
}
|
||||
|
||||
Sample<T> &operator-=(const Sample<T> &other)
|
||||
constexpr Sample<T> &operator-=(const Sample<T> &other)
|
||||
{
|
||||
download -= other.download;
|
||||
upload -= other.upload;
|
||||
upload -= other.upload;
|
||||
return *this;
|
||||
}
|
||||
|
||||
T download;
|
||||
T upload;
|
||||
T download {};
|
||||
T upload {};
|
||||
};
|
||||
|
||||
typedef Sample<qlonglong> SpeedSample;
|
||||
|
Loading…
x
Reference in New Issue
Block a user