Why my lambda doesn't put elements in vector?
void generate_N_numbers_in_the_vector(std::vector<int> &vec, int &M,
const int &N) {
std::random_device rand;
static std::mt19937 gen(rand());
static std::uniform_int_distribution<int> distribution(0, M);
vec.reserve(N);
std::generate(vec.begin(), vec.end(), []() { return distribution(gen); });
for (auto elem : vec) std::cout << elem << std::endl;
}
Aucun commentaire:
Enregistrer un commentaire