lundi 26 octobre 2015

no known conversion for argument from ‘std::exponential_distribution

I don't quite understand this error g++ is throwing at me.

What is the difference between std::exponential_distribution<double> (*)(double) and std::exponential_distribution<double>* ?

The second is clearly a pointer to a std::exponential_distribution with template argument <double>, but what is the first?

Here is the code which causes the problem:

Firstly the function prototype

simulation(std::mt19937_64 *mt19937_64_pointer,
           std::uniform_real_distribution<double> *uniform_real_dis_p,
           std::exponential_distribution<double> *exp_dis_p)
{
    ...
}

And the code which calls this function:

std::mt19937_64 *gen_p = nullptr; // <-- this used to be: *&gen_p - hence the problem
    // Actually it isn't equal to nullptr - this is set elsewhere in the code

std::uniform_real_distribution<double> uniform_real_dis(0.0, 1.0);
std::exponential_distribution<double> exp_dis(1.0);

simulation s(gen_p, &uniform_real_dis, &exp_dis);

This is a bit of a strange error - I'm sure I could fix it if I understood fully what it meant. It does seem strange to me that the uniform distribution works and the exponential doesn't?




Aucun commentaire:

Enregistrer un commentaire