Why is std::equal_to useful?

To be used in algorithms. It provides a functor with operator() on it, and thus can be used generically.

Specific (and contrived) example, as asked in comments:

// compare two sequences and produce a third one
// having true for positions where both sequences
// have equal elements
std::transform(seq1.begin(), seq1.end(), seq2.begin(), 
               std::inserter(resul), std::equal_to<>()); 

Not sure who might need it, but it is an example.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)