lundi 25 mars 2019

universal reference for predicate in std::find_if()?

std::find_if's UnaryPredicate is by value. Why cannot we have it by universal reference? i.e.

template< class InputIt, class UnaryPredicate >
InputIt find_if( InputIt first, InputIt last, 
                 UnaryPredicate&& p );

Is it mostly for historical reasons, or is there reason to prefer pass by value over universal reference in this case even with c++11?

Related questions: Passing functor object by value vs by reference (C++), Why does std::find_if(first, last, p) not take predicate by reference?

Aucun commentaire:

Enregistrer un commentaire