Utils: Add more constexpr to SmallString

Change-Id: I480ef040a8d9c5b9edc515c7fd58db2fad42dc86
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
Marco Bubke
2017-08-29 13:02:28 +02:00
parent 2bc537ca6b
commit 881cd5a799
3 changed files with 6 additions and 2 deletions

View File

@@ -39,6 +39,7 @@ template <class Category,
typename Reference = Type&> typename Reference = Type&>
struct SmallStringIterator : public std::iterator<Category, Type, DistanceType, Pointer, Reference> struct SmallStringIterator : public std::iterator<Category, Type, DistanceType, Pointer, Reference>
{ {
constexpr
SmallStringIterator() noexcept = default; SmallStringIterator() noexcept = default;
constexpr constexpr

View File

@@ -66,11 +66,13 @@ public:
return Q_LIKELY(isShortString()) ? m_data.shortString.shortStringSize : m_data.allocated.data.size; return Q_LIKELY(isShortString()) ? m_data.shortString.shortStringSize : m_data.allocated.data.size;
} }
constexpr
const_iterator begin() const noexcept const_iterator begin() const noexcept
{ {
return data(); return data();
} }
constexpr
const_iterator end() const noexcept const_iterator end() const noexcept
{ {
return data() + size(); return data() + size();
@@ -102,6 +104,7 @@ public:
return m_data.shortString.isReadOnlyReference; return m_data.shortString.isReadOnlyReference;
} }
constexpr
operator SmallStringView() const operator SmallStringView() const
{ {
return SmallStringView(data(), size()); return SmallStringView(data(), size());

View File

@@ -97,11 +97,13 @@ public:
return m_size == 0; return m_size == 0;
} }
constexpr
const_iterator begin() const noexcept const_iterator begin() const noexcept
{ {
return data(); return data();
} }
constexpr
const_iterator end() const noexcept const_iterator end() const noexcept
{ {
return data() + size(); return data() + size();
@@ -140,8 +142,6 @@ public:
return m_pointer[0] == characterToSearch; return m_pointer[0] == characterToSearch;
} }
private: private:
const char *m_pointer; const char *m_pointer;
size_type m_size; size_type m_size;