Skip to content

Commit

Permalink
Remove usage of std::binary_function and std::bind1st.
Browse files Browse the repository at this point in the history
- Deprectated since C++11, removed in C++17
  • Loading branch information
wo80 committed Jan 1, 2024
1 parent 38bd16b commit 4c27b35
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/algorithms/highlevel/chromaprinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ void Chromaprinter::compute() {
// Copy the signal to new vector to expand it to the int16_t dynamic range before the cast.
std::vector<Real> signalScaled = signal;
std::transform(signalScaled.begin(), signalScaled.end(), signalScaled.begin(),
std::bind1st(std::multiplies<Real>(), pow(2,15)));
std::bind(std::multiplies<Real>(), pow(2,15), std::placeholders::_1));

std::vector<int16_t> signalCast(signalScaled.begin(), signalScaled.end());

Expand Down Expand Up @@ -160,7 +160,7 @@ AlgorithmStatus Chromaprinter::process() {
// Copy the signal to new vector to expand it to the int16_t dynamic range before the cast.
std::vector<Real> signalScaled = signal;
std::transform(signalScaled.begin(), signalScaled.end(), signalScaled.begin(),
std::bind1st(std::multiplies<Real>(), pow(2,15)));
std::bind(std::multiplies<Real>(), pow(2,15), std::placeholders::_1));

std::vector<int16_t> signalCast(signalScaled.begin(), signalScaled.end());

Expand Down
2 changes: 1 addition & 1 deletion src/essentia/essentiamath.h
Original file line number Diff line number Diff line change
Expand Up @@ -831,7 +831,7 @@ std::vector<T> derivative(const std::vector<T>& array) {
}

template<typename T, typename U, typename Comparator=std::greater<T> >
class PairCompare : public std::binary_function<T, U, bool> {
class PairCompare {
Comparator _cmp;
public:
bool operator () (const std::pair<T,U>& p1, const std::pair<T,U>& p2) const {
Expand Down
3 changes: 1 addition & 2 deletions src/essentia/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,7 @@ inline bool case_insensitive_char_cmp(char a, char b) {
/**
* Function object for comparing two strings in a case-insensitive manner.
*/
struct case_insensitive_str_cmp
: public std::binary_function<const std::string&, const std::string&, bool> {
struct case_insensitive_str_cmp {
bool operator()(const std::string& str1, const std::string& str2) const {
return std::lexicographical_compare(str1.begin(), str1.end(),
str2.begin(), str2.end(),
Expand Down
4 changes: 2 additions & 2 deletions src/essentia/utils/peak.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class Peak {
// the positions are equal it sorts by descending magnitude
template<typename Comp1=std::less<Real>,
typename Comp2=std::greater_equal<Real> >
class ComparePeakPosition : public std::binary_function<Real, Real, bool> {
class ComparePeakPosition {
Comp1 _cmp1;
Comp2 _cmp2;
public:
Expand All @@ -86,7 +86,7 @@ class ComparePeakPosition : public std::binary_function<Real, Real, bool> {
// the magnitudes are equal it sorts by ascending position
template<typename Comp1=std::greater<Real>,
typename Comp2=std::less_equal<Real> >
class ComparePeakMagnitude : public std::binary_function<Real, Real, bool> {
class ComparePeakMagnitude {
Comp1 _cmp1;
Comp2 _cmp2;
public:
Expand Down

0 comments on commit 4c27b35

Please sign in to comment.