From c6604734c903310a2a5f04404a201dfdb4ca6a3b Mon Sep 17 00:00:00 2001 From: Jonas Kvinge Date: Fri, 26 Mar 2021 23:33:56 +0100 Subject: [PATCH] Remove using std::placeholders --- src/collection/collectionmodel.cpp | 5 +---- src/collection/groupbydialog.cpp | 4 ---- src/context/contextalbumsmodel.cpp | 5 +---- src/core/mergedproxymodel.cpp | 4 ---- src/core/songloader.cpp | 4 +--- src/device/giolister.cpp | 12 ++++-------- src/internet/internetsearchview.cpp | 3 --- src/organize/organize.cpp | 4 +--- src/playlist/playlist.cpp | 17 +++++++---------- src/playlist/playlistbackend.cpp | 2 -- 10 files changed, 15 insertions(+), 45 deletions(-) diff --git a/src/collection/collectionmodel.cpp b/src/collection/collectionmodel.cpp index 3d357ebc..83b97d3c 100644 --- a/src/collection/collectionmodel.cpp +++ b/src/collection/collectionmodel.cpp @@ -70,9 +70,6 @@ #include "covermanager/albumcoverloaderresult.h" #include "settings/collectionsettingspage.h" -using std::placeholders::_1; -using std::placeholders::_2; - const char *CollectionModel::kSavedGroupingsSettingsGroup = "SavedGroupings"; const int CollectionModel::kPrettyCoverSize = 32; const char *CollectionModel::kPixmapDiskCacheDir = "pixmapcache"; @@ -1773,7 +1770,7 @@ void CollectionModel::GetChildSongs(CollectionItem *item, QList *urls, Son const_cast(this)->LazyPopulate(item); QList children = item->children; - std::sort(children.begin(), children.end(), std::bind(&CollectionModel::CompareItems, this, _1, _2)); + std::sort(children.begin(), children.end(), std::bind(&CollectionModel::CompareItems, this, std::placeholders::_1, std::placeholders::_2)); for (CollectionItem *child : children) GetChildSongs(child, urls, songs, song_ids); diff --git a/src/collection/groupbydialog.cpp b/src/collection/groupbydialog.cpp index 908302ce..86ecb2f0 100644 --- a/src/collection/groupbydialog.cpp +++ b/src/collection/groupbydialog.cpp @@ -33,10 +33,6 @@ #include "groupbydialog.h" #include "ui_groupbydialog.h" -// boost::multi_index still relies on these being in the global namespace. -using std::placeholders::_1; -using std::placeholders::_2; - #include #include #include diff --git a/src/context/contextalbumsmodel.cpp b/src/context/contextalbumsmodel.cpp index 44dee58c..7c802329 100644 --- a/src/context/contextalbumsmodel.cpp +++ b/src/context/contextalbumsmodel.cpp @@ -54,9 +54,6 @@ #include "contextalbumsmodel.h" -using std::placeholders::_1; -using std::placeholders::_2; - const int ContextAlbumsModel::kPrettyCoverSize = 32; ContextAlbumsModel::ContextAlbumsModel(CollectionBackend *backend, Application *app, QObject *parent) : @@ -464,7 +461,7 @@ void ContextAlbumsModel::GetChildSongs(CollectionItem *item, QList *urls, const_cast(this)->LazyPopulate(item); QList children = item->children; - std::sort(children.begin(), children.end(), std::bind(&ContextAlbumsModel::CompareItems, this, _1, _2)); + std::sort(children.begin(), children.end(), std::bind(&ContextAlbumsModel::CompareItems, this, std::placeholders::_1, std::placeholders::_2)); for (CollectionItem *child : children) GetChildSongs(child, urls, songs, song_ids); diff --git a/src/core/mergedproxymodel.cpp b/src/core/mergedproxymodel.cpp index 260e5db6..3749d918 100644 --- a/src/core/mergedproxymodel.cpp +++ b/src/core/mergedproxymodel.cpp @@ -34,10 +34,6 @@ #include "mergedproxymodel.h" -// boost::multi_index still relies on these being in the global namespace. -using std::placeholders::_1; -using std::placeholders::_2; - #include #include #include diff --git a/src/core/songloader.cpp b/src/core/songloader.cpp index e3a3cd5d..44dd2ab9 100644 --- a/src/core/songloader.cpp +++ b/src/core/songloader.cpp @@ -65,8 +65,6 @@ # include "device/cddasongloader.h" #endif -using std::placeholders::_1; - QSet SongLoader::sRawUriSchemes; const int SongLoader::kDefaultTimeout = 5000; @@ -431,7 +429,7 @@ SongLoader::Result SongLoader::LoadRemote() { timeout_timer_->start(timeout_); // Create the pipeline - it gets unreffed if it goes out of scope - std::shared_ptr pipeline(gst_pipeline_new(nullptr), std::bind(&gst_object_unref, _1)); + std::shared_ptr pipeline(gst_pipeline_new(nullptr), std::bind(&gst_object_unref, std::placeholders::_1)); // Create the source element automatically based on the URL GstElement *source = gst_element_make_from_uri(GST_URI_SRC, url_.toEncoded().constData(), nullptr, nullptr); diff --git a/src/device/giolister.cpp b/src/device/giolister.cpp index e6a7c201..eaa7669b 100644 --- a/src/device/giolister.cpp +++ b/src/device/giolister.cpp @@ -43,10 +43,6 @@ #include "devicelister.h" #include "giolister.h" -using std::placeholders::_1; -using std::placeholders::_2; -using std::placeholders::_3; - QString GioLister::DeviceInfo::unique_id() const { if (!volume_root_uri.isEmpty()) return volume_root_uri; @@ -86,7 +82,7 @@ void OperationFinished(F f, GObject *object, GAsyncResult *result) { } void GioLister::VolumeMountFinished(GObject *object, GAsyncResult *result, gpointer) { - OperationFinished(std::bind(g_volume_mount_finish, _1, _2, _3), object, result); + OperationFinished(std::bind(g_volume_mount_finish, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3), object, result); } bool GioLister::Init() { @@ -537,15 +533,15 @@ QString GioLister::FindUniqueIdByVolume(GVolume *volume) const { } void GioLister::VolumeEjectFinished(GObject *object, GAsyncResult *result, gpointer) { - OperationFinished(std::bind(g_volume_eject_with_operation_finish, _1, _2, _3), object, result); + OperationFinished(std::bind(g_volume_eject_with_operation_finish, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3), object, result); } void GioLister::MountEjectFinished(GObject *object, GAsyncResult *result, gpointer) { - OperationFinished(std::bind(g_mount_eject_with_operation_finish, _1, _2, _3), object, result); + OperationFinished(std::bind(g_mount_eject_with_operation_finish, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3), object, result); } void GioLister::MountUnmountFinished(GObject *object, GAsyncResult *result, gpointer) { - OperationFinished(std::bind(g_mount_unmount_with_operation_finish, _1, _2, _3), object, result); + OperationFinished(std::bind(g_mount_unmount_with_operation_finish, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3), object, result); } void GioLister::UpdateDeviceFreeSpace(const QString &id) { diff --git a/src/internet/internetsearchview.cpp b/src/internet/internetsearchview.cpp index 2f4d975e..c6b810d9 100644 --- a/src/internet/internetsearchview.cpp +++ b/src/internet/internetsearchview.cpp @@ -87,9 +87,6 @@ #include "ui_internetsearchview.h" #include "settings/appearancesettingspage.h" -using std::placeholders::_1; -using std::placeholders::_2; - const int InternetSearchView::kSwapModelsTimeoutMsec = 250; const int InternetSearchView::kDelayedSearchTimeoutMs = 200; const int InternetSearchView::kArtHeight = 32; diff --git a/src/organize/organize.cpp b/src/organize/organize.cpp index 4f9dd8bb..0a113bdf 100644 --- a/src/organize/organize.cpp +++ b/src/organize/organize.cpp @@ -47,8 +47,6 @@ class OrganizeFormat; -using std::placeholders::_1; - const int Organize::kBatchSize = 10; #ifdef HAVE_GSTREAMER const int Organize::kTranscodeProgressInterval = 500; @@ -245,7 +243,7 @@ void Organize::ProcessSomeFiles() { job.cover_dest_ = QFileInfo(job.destination_).path() + "/" + QFileInfo(job.cover_source_).fileName(); } - job.progress_ = std::bind(&Organize::SetSongProgress, this, _1, !task.transcoded_filename_.isEmpty()); + job.progress_ = std::bind(&Organize::SetSongProgress, this, std::placeholders::_1, !task.transcoded_filename_.isEmpty()); if (!destination_->CopyToStorage(job)) { files_with_errors_ << task.song_info_.song_.basefilename(); diff --git a/src/playlist/playlist.cpp b/src/playlist/playlist.cpp index 20f28ff4..6346ad35 100644 --- a/src/playlist/playlist.cpp +++ b/src/playlist/playlist.cpp @@ -90,9 +90,6 @@ #include "internet/internetplaylistitem.h" #include "internet/internetsongmimedata.h" -using std::placeholders::_1; -using std::placeholders::_2; - const char *Playlist::kCddaMimeType = "x-content/audio-cdda"; const char *Playlist::kRowsMimetype = "application/x-strawberry-playlist-rows"; const char *Playlist::kPlayNowMimetype = "application/x-strawberry-play-now"; @@ -1336,17 +1333,17 @@ void Playlist::sort(int column, Qt::SortOrder order) { if (column == Column_Album) { // When sorting by album, also take into account discs and tracks. - std::stable_sort(begin, new_items.end(), std::bind(&Playlist::CompareItems, Column_Track, order, _1, _2)); - std::stable_sort(begin, new_items.end(), std::bind(&Playlist::CompareItems, Column_Disc, order, _1, _2)); - std::stable_sort(begin, new_items.end(), std::bind(&Playlist::CompareItems, Column_Album, order, _1, _2)); + std::stable_sort(begin, new_items.end(), std::bind(&Playlist::CompareItems, Column_Track, order, std::placeholders::_1, std::placeholders::_2)); + std::stable_sort(begin, new_items.end(), std::bind(&Playlist::CompareItems, Column_Disc, order, std::placeholders::_1, std::placeholders::_2)); + std::stable_sort(begin, new_items.end(), std::bind(&Playlist::CompareItems, Column_Album, order, std::placeholders::_1, std::placeholders::_2)); } else if (column == Column_Filename) { // When sorting by full paths we also expect a hierarchical order. This returns a breath-first ordering of paths. - std::stable_sort(begin, new_items.end(), std::bind(&Playlist::CompareItems, Column_Filename, order, _1, _2)); - std::stable_sort(begin, new_items.end(), std::bind(&Playlist::ComparePathDepths, order, _1, _2)); + std::stable_sort(begin, new_items.end(), std::bind(&Playlist::CompareItems, Column_Filename, order, std::placeholders::_1, std::placeholders::_2)); + std::stable_sort(begin, new_items.end(), std::bind(&Playlist::ComparePathDepths, order, std::placeholders::_1, std::placeholders::_2)); } else { - std::stable_sort(begin, new_items.end(), std::bind(&Playlist::CompareItems, column, order, _1, _2)); + std::stable_sort(begin, new_items.end(), std::bind(&Playlist::CompareItems, column, order, std::placeholders::_1, std::placeholders::_2)); } undo_stack_->push(new PlaylistUndoCommands::SortItems(this, column, order, new_items)); @@ -1885,7 +1882,7 @@ void Playlist::ReshuffleIndices() { } // Sort the virtual items - std::stable_sort(begin, end, std::bind(AlbumShuffleComparator, album_key_positions, album_keys, _1, _2)); + std::stable_sort(begin, end, std::bind(AlbumShuffleComparator, album_key_positions, album_keys, std::placeholders::_1, std::placeholders::_2)); break; } diff --git a/src/playlist/playlistbackend.cpp b/src/playlist/playlistbackend.cpp index 0a775300..dc82c928 100644 --- a/src/playlist/playlistbackend.cpp +++ b/src/playlist/playlistbackend.cpp @@ -57,8 +57,6 @@ #include "playlistparsers/cueparser.h" #include "smartplaylists/playlistgenerator.h" -using std::placeholders::_1; - const int PlaylistBackend::kSongTableJoins = 2; PlaylistBackend::PlaylistBackend(Application *app, QObject *parent)