I'm fairly sure this exists in the std `<algorithms>` header. Could be wrong though.