mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-11 07:18:08 +00:00
Add constexpr to IndexInterval class
Add const to IndexRange private members. Remove redundant inline specifier. Add missing parentheses.
This commit is contained in:
parent
9631a9c2ad
commit
e099f6ad33
@ -38,30 +38,30 @@ class IndexInterval
|
|||||||
public:
|
public:
|
||||||
using IndexType = Index;
|
using IndexType = Index;
|
||||||
|
|
||||||
IndexInterval(IndexType first, IndexType last)
|
IndexInterval(IndexType first, IndexType last) // add constexpr when using C++14
|
||||||
: m_first {first}
|
: m_first {first}
|
||||||
, m_last {last}
|
, m_last {last}
|
||||||
{
|
{
|
||||||
Q_ASSERT(first <= last);
|
Q_ASSERT(first <= last);
|
||||||
}
|
}
|
||||||
|
|
||||||
IndexType first() const
|
constexpr IndexType first() const
|
||||||
{
|
{
|
||||||
return m_first;
|
return m_first;
|
||||||
}
|
}
|
||||||
|
|
||||||
IndexType last() const
|
constexpr IndexType last() const
|
||||||
{
|
{
|
||||||
return m_last;
|
return m_last;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
IndexType m_first;
|
const IndexType m_first;
|
||||||
IndexType m_last;
|
const IndexType m_last;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
inline IndexInterval<T> makeInterval(T first, T last)
|
constexpr IndexInterval<T> makeInterval(T first, T last)
|
||||||
{
|
{
|
||||||
return {first, last};
|
return {first, last};
|
||||||
}
|
}
|
||||||
@ -99,7 +99,7 @@ public:
|
|||||||
|
|
||||||
constexpr IndexType end() const
|
constexpr IndexType end() const
|
||||||
{
|
{
|
||||||
return m_first + m_size;
|
return (m_first + m_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr IndexDiffType size() const
|
constexpr IndexDiffType size() const
|
||||||
@ -114,12 +114,12 @@ public:
|
|||||||
|
|
||||||
constexpr IndexType last() const
|
constexpr IndexType last() const
|
||||||
{
|
{
|
||||||
return m_first + m_size - 1;
|
return (m_first + m_size - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr bool isEmpty() const
|
constexpr bool isEmpty() const
|
||||||
{
|
{
|
||||||
return m_size == 0;
|
return (m_size == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Loading…
Reference in New Issue
Block a user