c++ - 从 ‘std::exponential_distribution<double> (*)(double)’ 到 ‘std::exponential_distribution<double>*' 的参数没有已知的转换

标签 c++ c++11 random standard-library c++-standard-library

<分区>

我不太明白这个错误g++向我 throw 。

std::exponential_distribution<double> (*)(double) 之间有什么区别?和 std::exponential_distribution<double>*

第二个显然是指向 std::exponential_distribution 的指针使用模板参数 <double> , 但第一个是什么?

这是导致问题的代码:

首先是函数原型(prototype)

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

调用这个函数的代码:

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);

这是一个有点奇怪的错误 - 如果我完全理解它的含义,我相信我可以修复它。均匀分布起作用而指数分布不起作用对我来说确实很奇怪?

最佳答案

您已从评论中得到答案,但仅作记录,std::exponential_distribution<double> (*)(double)是一个函数指针类型:一个接受一个 double 的函数并返回 std::exponential_distribution<double> .

关于c++ - 从 ‘std::exponential_distribution<double> (*)(double)’ 到 ‘std::exponential_distribution<double>*' 的参数没有已知的转换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33350790/

相关文章:

c++ - MFC 消息队列限制

c++ - 基于 boost::asio 的慢速 http 客户端 - (分块传输)

bash - bash 中 $RANDOM 环境变量的种子

c++ - 删除不必要的包含时的最佳实践是什么?

c++ 枚举范围无法使用 -std=c++98 编译,但可以使用 -std=c++11

C++ boost 错误

c++ - 私有(private)移动构造函数是为了防止移动吗?

c++ - 存储从字符串到整数的映射的最佳方式,同时反之亦然?

Javascript 计算 - NaN 消息

python - python随机模块的内部状态