I have implemented a comparison for struct Track in the function:
bool sortingPredicate(const Track& l, const Track& r)
then I have a function:
void sortPlaylist(std::list<Track>& playlist, bool (*predicate)(const Track& l, const Track& r)) {
playlist.sort(predicate);
}
And I have tried:
std::list<Track> mergeWithoutDuplicates(const std::list<Track>& l, const std::list<Track>& r) {
sortPlaylist(l, sortingPredicate<Track>());
...
}
And I get for the sortPlaylist-call:
error: expected primary-expression before ‘>’ token
error: expected primary-expression before ‘)’ token"
What am I missing in the function call / doing wrong? Many thanks.
is a function call, you’re not passing it as a callback. It should be:
also, note that
lisconstinsidemergeWithoutDuplicates, but you’re passing it tosortPlaylistwhich expects a non-constreference. That’s also wrong.