mercredi 4 février 2015

use std::uniform_int_distribution in struct and define it's range latter

I have problem where I want to use std::uniform_int_distribution in struct and then give it' range. Below is what I want.



#include <random>
#include <iostream>

std::random_device rd;
std::mt19937 gen(rd());

struct group_s {
int k;
std::uniform_int_distribution<> dis;
} group;


int main()
{
group.dis(0,19);
std::cout << group.dis(gen) << ' ';
}


I am getting below error:



no match for call to '(std::uniform_int_distribution<>) (int, int)'
cpu_group.dis(0,19);


How to define the required functionality ?


Aucun commentaire:

Enregistrer un commentaire