QStringTokenizer: clean up Q_STRINGTOKENIZER_USE_SENTINEL

The macro was unconditionally defined since
44a74127954dce2416842a6644cbdff4c513b6fb and, despite being named like
a public Qt macro, never documented, so just remove it.

Also means we can remove the ODR protection from end() and cend() now.

[ChangeLog][Potentially Source-Incompatible Changes] The undocumented
Q_STRINGTOKENIZER_USE_SENTINEL macro was removed. It was
unconditionally defined since Qt 6.0.

Change-Id: I8ba2aeddea79ad89cef8912e9cf34098f2793f1b
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 799e16149ce9d34419da9ea35f790412202ce7a8)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Marc Mutz 2024-08-27 08:40:25 +02:00 committed by Qt Cherry-pick Bot
parent f85f5b35bb
commit 99f8efd0ef

View File

@ -11,8 +11,6 @@ QT_BEGIN_NAMESPACE
template <typename, typename> class QStringBuilder;
#define Q_STRINGTOKENIZER_USE_SENTINEL
class QStringTokenizerBaseBase
{
protected:
@ -48,14 +46,10 @@ public:
class iterator;
friend class iterator;
#ifdef Q_STRINGTOKENIZER_USE_SENTINEL
class sentinel {
friend constexpr bool operator==(sentinel, sentinel) noexcept { return true; }
friend constexpr bool operator!=(sentinel, sentinel) noexcept { return false; }
};
#else
using sentinel = iterator;
#endif
class iterator {
const QStringTokenizerBase *tokenizer;
next_result current;
@ -82,7 +76,6 @@ public:
{ return lhs.current.ok == rhs.current.ok && (!lhs.current.ok || (Q_ASSERT(lhs.tokenizer == rhs.tokenizer), lhs.current.state == rhs.current.state)); }
friend constexpr bool operator!=(const iterator &lhs, const iterator &rhs) noexcept
{ return !operator==(lhs, rhs); }
#ifdef Q_STRINGTOKENIZER_USE_SENTINEL
friend constexpr bool operator==(const iterator &lhs, sentinel) noexcept
{ return !lhs.current.ok; }
friend constexpr bool operator!=(const iterator &lhs, sentinel) noexcept
@ -91,7 +84,6 @@ public:
{ return !rhs.current.ok; }
friend constexpr bool operator!=(sentinel, const iterator &rhs) noexcept
{ return !operator==(sentinel{}, rhs); }
#endif
private:
void advance() {
Q_ASSERT(current.ok);
@ -110,9 +102,7 @@ public:
[[nodiscard]] iterator begin() const noexcept { return iterator{*this}; }
[[nodiscard]] iterator cbegin() const noexcept { return begin(); }
template <bool = std::is_same<iterator, sentinel>::value> // ODR protection
[[nodiscard]] constexpr sentinel end() const noexcept { return {}; }
template <bool = std::is_same<iterator, sentinel>::value> // ODR protection
[[nodiscard]] constexpr sentinel cend() const noexcept { return {}; }
private: