I stumbled upon this while trying something equivalent to
#include <vector>
#include <algorithm>
struct pred { //not copyable
pred () {}
bool operator()(int) const { return false; }
pred( pred && ) {}
};
int main () {
std::vector<int> a{1,2,3};
std::vector<int> b{};
auto p = pred{};
//std::copy_if(a.begin(), a.end(), std::back_inserter(b), p); // this fails
std::copy_if(a.begin(), a.end(), std::back_inserter(b), std::move(p));
}
see https://godbolt.org/z/wDvO3K
Why can stl algorithms not accept universal references for the "operations"?
PS: Apologies if this is a duplicate, I would be surprised if it isn't..