std::function is allowed to heap allocate in order to hold any necessary captures, so we should be std::move-ing instances here in order to avoid potentially performing reallocations.