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_wrapper
explains thatstd::sort
now acceptsstd::reference_wrapper
, allowing one to pass a comparator by reference.Is there a reason
std::sort
didn't accept the comparator by reference in the first place?
Add a Comment
Comments are closed.