Quick A: By design, because function objects are expected to be nonstateful values.
Recently on SO:
Why doesn't std::sort accept comparator by reference?
The standard on
std::reference_wrapperexplains thatstd::sortnow acceptsstd::reference_wrapper, allowing one to pass a comparator by reference.Is there a reason
std::sortdidn't accept the comparator by reference in the first place?

Add a Comment
Comments are closed.