std::generate
takes a function object and applies its return value to the sequence container. But std::uniform_int_distribution<T>::operator ()
doesn't return a function object, it actually generates the random value and returns it. If you want to pass a functor, use a lambda:
std::generate(k.begin(), k.end(), [&] { return d(mt); });
// ^^^^^^^^^^^^^^^^^^^^^