From 955b906b52a6e96fb2d82947a92f0dc374df98d0 Mon Sep 17 00:00:00 2001 From: Jonas Kvinge Date: Tue, 30 Jul 2019 21:31:26 +0200 Subject: [PATCH] Add Song() != operator --- src/core/song.cpp | 4 ++++ src/core/song.h | 1 + 2 files changed, 5 insertions(+) diff --git a/src/core/song.cpp b/src/core/song.cpp index ddf25591f..1f09e42be 100644 --- a/src/core/song.cpp +++ b/src/core/song.cpp @@ -1357,6 +1357,10 @@ bool Song::operator==(const Song &other) const { return url() == other.url() && beginning_nanosec() == other.beginning_nanosec(); } +bool Song::operator!=(const Song &other) const { + return id() != other.id() || url() != other.url() || beginning_nanosec() != other.beginning_nanosec(); +} + uint qHash(const Song &song) { // Should compare the same fields as operator== return qHash(song.url().toString()) ^ qHash(song.beginning_nanosec()); diff --git a/src/core/song.h b/src/core/song.h index a815d7476..45b9c2682 100644 --- a/src/core/song.h +++ b/src/core/song.h @@ -342,6 +342,7 @@ class Song { bool IsSimilar(const Song &other) const; bool operator==(const Song &other) const; + bool operator!=(const Song &other) const; // Two songs that are on the same album will have the same AlbumKey. // It is more efficient to use IsOnSameAlbum, but this function can be used when you need to hash the key to do fast lookups.