https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70898
--- Comment #2 from Marc Glisse <glisse at gcc dot gnu.org> --- I think you are supposed to use std::reference_wrapper<Comp> as comparator if you don't want to copy it around. We did talk about reducing the number of copies (mostly in the context of sorting), but nobody has found the time / motivation to write patches.