Browse Source

Add constexpr to IndexInterval class

Add const to IndexRange private members.
Remove redundant inline specifier.
Add missing parentheses.
adaptive-webui-19844
Chocobo1 7 years ago
parent
commit
e099f6ad33
No known key found for this signature in database
GPG Key ID: 210D9C873253A68C
  1. 18
      src/base/indexrange.h

18
src/base/indexrange.h

@ -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…
Cancel
Save