I noticed that some std classes/functions take function parameter by value and some by reference.
For instance, std::sort takes comparison function by value:
template<... class Compare>
void sort( ..., Compare comp )
And std::set constructor takes comparison function by reference:
template<... class Compare>
class set
{
explicit set( const Compare& comp, ... )
...
}
Why this difference, and in what cases is one or the other method preferred?
Aucun commentaire:
Enregistrer un commentaire