Skip to content

Commit

Permalink
Introduce wrapper for non const iterators for erase and insert
Browse files Browse the repository at this point in the history
  • Loading branch information
daschuer committed Oct 20, 2023
1 parent 920fa8a commit 363b0e2
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/preferences/dialog/dlgprefmixer.cpp
Expand Up @@ -56,7 +56,7 @@ constexpr int kFrequencyLowerLimit = 16;
constexpr int kXfaderGridHLines = 3;
constexpr int kXfaderGridVLines = 5;

bool isMixingEQ(EffectManifest* pManifest) {
bool isMixingEQ(const EffectManifest* pManifest) {
return pManifest->isMixingEQ();
}

Expand Down Expand Up @@ -1175,11 +1175,11 @@ const QList<EffectManifestPointer> DlgPrefMixer::getDeckEqManifests() const {
allManifests.end(),
[](const auto& pManifest) { return isMixingEQ(pManifest.data()); });
if (m_eqEffectsOnly) {
constErase(&allManifests, nonEqsStartIt, allManifests.end());
erase(&allManifests, nonEqsStartIt, allManifests.end());
} else {
// Add a null item between EQs and non-EQs. The combobox fill function
// will use this to insert a separator.
constInsert(&allManifests, nonEqsStartIt, EffectManifestPointer());
insert(&allManifests, nonEqsStartIt, EffectManifestPointer());
}
return allManifests;
}
Expand Down
27 changes: 27 additions & 0 deletions src/util/make_const_iterator.h
Expand Up @@ -34,6 +34,15 @@ typename C::const_iterator constErase(C* pContainer, I begin, I end) {
#endif
}

template<typename C, typename I>
typename C::iterator erase(C* pContainer, I begin, I end) {
#if defined(QT_VERSION) && QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
return pContainer->erase(C::const_iterator > (begin), C::const_iterator > (end));

Check failure on line 40 in src/util/make_const_iterator.h

View workflow job for this annotation

GitHub Actions / clazy

missing 'typename' prior to dependent type name 'QList<QSharedPointer<EffectManifest>>::const_iterator'

Check failure on line 40 in src/util/make_const_iterator.h

View workflow job for this annotation

GitHub Actions / Ubuntu 22.04

dependent-name ‘C::const_iterator’ is parsed as a non-type, but instantiation yields a type

Check failure on line 40 in src/util/make_const_iterator.h

View workflow job for this annotation

GitHub Actions / Ubuntu 22.04

dependent-name ‘C::const_iterator’ is parsed as a non-type, but instantiation yields a type

Check failure on line 40 in src/util/make_const_iterator.h

View workflow job for this annotation

GitHub Actions / Ubuntu 22.04 (QML)

dependent-name ‘C::const_iterator’ is parsed as a non-type, but instantiation yields a type

Check failure on line 40 in src/util/make_const_iterator.h

View workflow job for this annotation

GitHub Actions / Ubuntu 22.04 (QML)

dependent-name ‘C::const_iterator’ is parsed as a non-type, but instantiation yields a type

Check failure on line 40 in src/util/make_const_iterator.h

View workflow job for this annotation

GitHub Actions / coverage

dependent-name ‘C::const_iterator’ is parsed as a non-type, but instantiation yields a type

Check failure on line 40 in src/util/make_const_iterator.h

View workflow job for this annotation

GitHub Actions / coverage

dependent-name ‘C::const_iterator’ is parsed as a non-type, but instantiation yields a type

Check failure on line 40 in src/util/make_const_iterator.h

View workflow job for this annotation

GitHub Actions / macOS 11 x64

missing 'typename' prior to dependent type name 'QList<QSharedPointer<EffectManifest>>::const_iterator'

Check failure on line 40 in src/util/make_const_iterator.h

View workflow job for this annotation

GitHub Actions / macOS 11 arm64

missing 'typename' prior to dependent type name 'QList<QSharedPointer<EffectManifest>>::const_iterator'
#else
return pContainer->erase(begin, end);
#endif
}

template<typename C, typename I>
typename C::const_iterator constErase(C* pContainer, I it) {
#if defined(QT_VERSION) && QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
Expand All @@ -43,6 +52,15 @@ typename C::const_iterator constErase(C* pContainer, I it) {
#endif
}

template<typename C, typename I>
typename C::iterator erase(C* pContainer, I it) {
#if defined(QT_VERSION) && QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
return pContainer->erase(C::const_iterator > (it));
#else
return pContainer->erase(it);
#endif
}

template<typename C, typename I, class T>
typename C::const_iterator constInsert(C* pContainer, I before, T t) {
#if defined(QT_VERSION) && QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
Expand All @@ -52,3 +70,12 @@ typename C::const_iterator constInsert(C* pContainer, I before, T t) {
pContainer->insert(make_iterator(pContainer, before), t));
#endif
}

template<typename C, typename I, class T>
typename C::iterator insert(C* pContainer, I before, T t) {
#if defined(QT_VERSION) && QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
return pContainer->insert(C::const_iterator > (before), std::move(t));

Check failure on line 77 in src/util/make_const_iterator.h

View workflow job for this annotation

GitHub Actions / clazy

missing 'typename' prior to dependent type name 'QList<QSharedPointer<EffectManifest>>::const_iterator'

Check failure on line 77 in src/util/make_const_iterator.h

View workflow job for this annotation

GitHub Actions / Ubuntu 22.04

dependent-name ‘C::const_iterator’ is parsed as a non-type, but instantiation yields a type

Check failure on line 77 in src/util/make_const_iterator.h

View workflow job for this annotation

GitHub Actions / Ubuntu 22.04 (QML)

dependent-name ‘C::const_iterator’ is parsed as a non-type, but instantiation yields a type

Check failure on line 77 in src/util/make_const_iterator.h

View workflow job for this annotation

GitHub Actions / coverage

dependent-name ‘C::const_iterator’ is parsed as a non-type, but instantiation yields a type

Check failure on line 77 in src/util/make_const_iterator.h

View workflow job for this annotation

GitHub Actions / macOS 11 x64

missing 'typename' prior to dependent type name 'QList<QSharedPointer<EffectManifest>>::const_iterator'

Check failure on line 77 in src/util/make_const_iterator.h

View workflow job for this annotation

GitHub Actions / macOS 11 arm64

missing 'typename' prior to dependent type name 'QList<QSharedPointer<EffectManifest>>::const_iterator'
#else
return pContainer->insert(before, t);
#endif
}

0 comments on commit 363b0e2

Please sign in to comment.