From cdf83ee792f0d0cf1afb38c1b59fd2f98c7c017f Mon Sep 17 00:00:00 2001 From: hjk Date: Fri, 31 Jul 2020 11:00:19 +0200 Subject: [PATCH] Utils: Use constexpr instead of constexpr17 Not needed anymore, we require C++17 nowadays. Change-Id: Idea34512314d4df619f48832ea9d7b4994586c14 Reviewed-by: Marco Bubke --- src/libs/utils/smallstringfwd.h | 6 ------ src/libs/utils/smallstringview.h | 20 ++++++++++---------- 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/src/libs/utils/smallstringfwd.h b/src/libs/utils/smallstringfwd.h index 0740cdf462b..d1e94fa227d 100644 --- a/src/libs/utils/smallstringfwd.h +++ b/src/libs/utils/smallstringfwd.h @@ -25,12 +25,6 @@ #pragma once -#if __cplusplus >= 201703L -#define constexpr17 constexpr -#else -#define constexpr17 inline -#endif - #if __cplusplus >= 202002L #define constexpr20 constexpr #else diff --git a/src/libs/utils/smallstringview.h b/src/libs/utils/smallstringview.h index 039dc245a50..5559d222322 100644 --- a/src/libs/utils/smallstringview.h +++ b/src/libs/utils/smallstringview.h @@ -54,7 +54,7 @@ public: constexpr SmallStringView() = default; - constexpr17 SmallStringView(const char *characterPointer) noexcept + constexpr SmallStringView(const char *characterPointer) noexcept : m_pointer(characterPointer) , m_size(std::char_traits::length(characterPointer)) {} @@ -77,7 +77,7 @@ public: , m_size(string.size()) {} - static constexpr17 SmallStringView fromUtf8(const char *const characterPointer) + static constexpr SmallStringView fromUtf8(const char *const characterPointer) { return SmallStringView(characterPointer); } @@ -130,12 +130,12 @@ public: return data() + size(); } - constexpr17 const_reverse_iterator rbegin() const noexcept + constexpr const_reverse_iterator rbegin() const noexcept { return const_reverse_iterator(end()); } - constexpr17 const_reverse_iterator rend() const noexcept + constexpr const_reverse_iterator rend() const noexcept { return const_reverse_iterator(begin()); } @@ -147,7 +147,7 @@ public: return QString::fromUtf8(data(), int(size())); } - constexpr17 bool startsWith(SmallStringView subStringToSearch) const noexcept + constexpr bool startsWith(SmallStringView subStringToSearch) const noexcept { if (size() >= subStringToSearch.size()) return !std::char_traits::compare(m_pointer, @@ -171,18 +171,18 @@ private: size_type m_size = 0; }; -constexpr17 bool operator==(SmallStringView first, SmallStringView second) noexcept +constexpr bool operator==(SmallStringView first, SmallStringView second) noexcept { return first.size() == second.size() && std::char_traits::compare(first.data(), second.data(), first.size()) == 0; } -constexpr17 bool operator!=(SmallStringView first, SmallStringView second) noexcept +constexpr bool operator!=(SmallStringView first, SmallStringView second) noexcept { return !(first == second); } -constexpr17 int compare(SmallStringView first, SmallStringView second) noexcept +constexpr int compare(SmallStringView first, SmallStringView second) noexcept { int sizeDifference = int(first.size() - second.size()); @@ -192,12 +192,12 @@ constexpr17 int compare(SmallStringView first, SmallStringView second) noexcept return sizeDifference; } -constexpr17 bool operator<(SmallStringView first, SmallStringView second) noexcept +constexpr bool operator<(SmallStringView first, SmallStringView second) noexcept { return compare(first, second) < 0; } -constexpr17 bool operator>(SmallStringView first, SmallStringView second) noexcept +constexpr bool operator>(SmallStringView first, SmallStringView second) noexcept { return second < first; }