reapack

Package manager for REAPER
Log | Files | Refs | Submodules | README | LICENSE

commit dccaed3aab9fb8823523a2d04827162a86dc6719
parent 4146c9489f24cc8a372aee50b589916916d47b66
Author: cfillion <cfillion@users.noreply.github.com>
Date:   Sat, 25 Aug 2018 23:22:23 -0400

use structured binding declaration in range-based loops

Diffstat:
Msrc/about.cpp | 14+++++++-------
Msrc/browser.cpp | 7+++----
Msrc/dialog.cpp | 4+---
Msrc/thread.cpp | 4++--
Msrc/transaction.cpp | 6+++---
Mtest/package.cpp | 8++++----
Mtest/platform.cpp | 6+++---
Mtest/source.cpp | 6+++---
Mwin32.tup | 3+--
9 files changed, 27 insertions(+), 31 deletions(-)

diff --git a/src/about.cpp b/src/about.cpp @@ -209,8 +209,8 @@ void About::setMetadata(const Metadata *metadata, const bool substitution) const int shift = (rect.right - rect.left) + 4; - for(const auto &pair : metadata->links()) { - const int control = getLinkControl(pair.first); + for(const auto &[type, link] : metadata->links()) { + const int control = getLinkControl(type); if(!m_links.count(control)) { HWND handle = getControl(control); @@ -223,7 +223,7 @@ void About::setMetadata(const Metadata *metadata, const bool substitution) m_links[control] = {}; } - m_links[control].push_back(&pair.second); + m_links[control].push_back(&link); } onResize(); // update the position of link buttons @@ -572,10 +572,10 @@ void AboutPackageDelegate::updateList(const int index) if(sections) { vector<string> sectionNames; - for(const auto &pair : sectionMap) { - if(sections & pair.first) { - sectionNames.push_back(pair.second); - sections &= ~pair.first; + for(const auto &[section, name] : sectionMap) { + if(sections & section) { + sectionNames.push_back(name); + sections &= ~section; } } diff --git a/src/browser.cpp b/src/browser.cpp @@ -333,11 +333,10 @@ void Browser::displayButton() if(!m_typeFilter) menu.checkRadio(index); - for(const auto &pair : types) { - auto index = menu.addAction(pair.first, - pair.second | (ACTION_FILTERTYPE << 8)); + for(const auto &[name, type] : types) { + auto index = menu.addAction(name, type | (ACTION_FILTERTYPE << 8)); - if(m_typeFilter && m_typeFilter == pair.second) + if(m_typeFilter && m_typeFilter == type) menu.checkRadio(index); } diff --git a/src/dialog.cpp b/src/dialog.cpp @@ -455,9 +455,7 @@ void Dialog::onNotify(LPNMHDR info, LPARAM lParam) void Dialog::onContextMenu(HWND target, const int x, const int y) { - for(const auto &pair : m_controls) { - Control *ctrl = pair.second; - + for(Control *ctrl : m_controls | boost::adaptors::map_values) { if(!IsWindowVisible(ctrl->handle())) continue; diff --git a/src/thread.cpp b/src/thread.cpp @@ -211,8 +211,8 @@ void ThreadNotifier::processQueue() lock_guard<mutex> guard(m_mutex); while(!m_queue.empty()) { - const Notification &notif = m_queue.front(); - notif.first->setState(notif.second); + const auto &[task, state] = m_queue.front(); + task->setState(state); m_queue.pop(); } } diff --git a/src/transaction.cpp b/src/transaction.cpp @@ -264,9 +264,9 @@ void Transaction::registerScript(const HostTicket &reg, const bool isLastCall) vector<int> sections; - for(const auto &pair : sectionMap) { - if(reg.file.sections & pair.first) - sections.push_back(pair.second); + for(const auto &[flag, id] : sectionMap) { + if(reg.file.sections & flag) + sections.push_back(id); } assert(!sections.empty()); // is a section missing in sectionMap? diff --git a/test/package.cpp b/test/package.cpp @@ -24,8 +24,8 @@ TEST_CASE("package type from string", M) { {"autoitem", Package::AutomationItemType}, }; - for(const auto &pair : tests) - REQUIRE(Package::getType(pair.first) == pair.second); + for(const auto &[typeString, typeId] : tests) + REQUIRE(Package::getType(typeString) == typeId); } TEST_CASE("package type to string", M) { @@ -45,8 +45,8 @@ TEST_CASE("package type to string", M) { {static_cast<Package::Type>(-1), "Unknown"}, }; - for(const auto &pair : tests) - REQUIRE(Package::displayType(pair.first) == pair.second); + for(const auto &[type, displayName] : tests) + REQUIRE(Package::displayType(type) == displayName); } TEST_CASE("invalid package name", M) { diff --git a/test/platform.cpp b/test/platform.cpp @@ -50,7 +50,7 @@ TEST_CASE("platform from string", M) { } TEST_CASE("test platform", M) { - const pair<Platform, bool> expected[] = { + const pair<Platform, bool> tests[] = { {Platform::GenericPlatform, true}, #ifdef __APPLE__ @@ -104,6 +104,6 @@ TEST_CASE("test platform", M) { #endif }; - for(const auto &it : expected) - REQUIRE(it.first.test() == it.second); + for(const auto &[platform, expected] : tests) + REQUIRE(platform.test() == expected); } diff --git a/test/source.cpp b/test/source.cpp @@ -148,9 +148,9 @@ TEST_CASE("source target path", M) { }; Source source("file.name", "url", &ver); - for(const auto &pair : tests) { - source.setTypeOverride(pair.first); - REQUIRE(source.targetPath() == Path(pair.second)); + for(const auto &[type, path] : tests) { + source.setTypeOverride(type); + REQUIRE(source.targetPath() == Path(path)); } } diff --git a/win32.tup b/win32.tup @@ -9,8 +9,7 @@ REAPACK_FILE := reaper_reapack@(SUFFIX) VCPKG = vendor/vcpkg/installed/@(VCPKG_TRIPLET) -CXXFLAGS := /nologo /W3 /WX /wd4996 /EHsc /MT -CXXFLAGS += /O2 /Z7 /Zo +CXXFLAGS := /nologo /std:c++17 /W3 /WX /wd4996 /EHsc /MT /O2 /Z7 /Zo CXXFLAGS += /Ivendor /I$(VCPKG)/include /Ivendor/WDL /Ivendor/WDL/WDL CXXFLAGS += /DWDL_NO_DEFINE_MINMAX /DCURL_STATICLIB /DUNICODE /DNDEBUG CXXFLAGS += /DREAPACK_FILE#\"$(REAPACK_FILE).dll\"