提升功能签名

Pet*_*217 1 c++ boost function signature

有人可以使用boost的正态分布告诉我这段代码发生了什么吗?

boost::mt19937 rng; // A random number generator
boost::normal_distribution<> nd(3.0, 1.0); // mean 3, sigma 1
// Attach the distribution to the random number generator to get a function
// that returns normally distributed variables.
boost::variate_generator<boost::mt19937&,boost::normal_distribution<> > var_nor(rng, nd);
// Use it. But why is function signature different?
double x = var_nor();
Run Code Online (Sandbox Code Playgroud)

我对var_nor及其两个函数签名发生了什么感到困惑.谢谢皮特

Mat*_*Mat 5

var_nor 它不是一个函数,它是一个对象.

第一行创建它(将rng和distribution作为参数传递给构造函数).
第二行称其operator()成员.