Use C++17 (#579)
* Use C++17 * Replace std::random_shuffle with std::shuffle * Add random include
This commit is contained in:
@@ -29,6 +29,7 @@
|
||||
#include <iterator>
|
||||
#include <type_traits>
|
||||
#include <unordered_map>
|
||||
#include <random>
|
||||
|
||||
#include <QtGlobal>
|
||||
#include <QObject>
|
||||
@@ -1819,6 +1820,9 @@ void Playlist::ReshuffleIndices() {
|
||||
if (current_virtual_index_ != -1)
|
||||
std::advance(begin, current_virtual_index_ + 1);
|
||||
|
||||
std::random_device rd;
|
||||
std::mt19937 g(rd());
|
||||
|
||||
switch (playlist_sequence_->shuffle_mode()) {
|
||||
case PlaylistSequence::Shuffle_Off:
|
||||
// Handled above.
|
||||
@@ -1826,7 +1830,7 @@ void Playlist::ReshuffleIndices() {
|
||||
|
||||
case PlaylistSequence::Shuffle_All:
|
||||
case PlaylistSequence::Shuffle_InsideAlbum:
|
||||
std::random_shuffle(begin, end);
|
||||
std::shuffle(begin, end, g);
|
||||
break;
|
||||
|
||||
case PlaylistSequence::Shuffle_Albums: {
|
||||
@@ -1843,7 +1847,7 @@ void Playlist::ReshuffleIndices() {
|
||||
|
||||
// Shuffle them
|
||||
QStringList shuffled_album_keys = album_key_set.values();
|
||||
std::random_shuffle(shuffled_album_keys.begin(), shuffled_album_keys.end());
|
||||
std::shuffle(shuffled_album_keys.begin(), shuffled_album_keys.end(), g);
|
||||
|
||||
// If the user is currently playing a song, force its album to be first
|
||||
// Or if the song was not playing but it was selected, force its album to be first.
|
||||
|
||||
Reference in New Issue
Block a user