B
Bill Woessner
I'm trying to replace a loop with a call to std::generate and I'm
about at wits end. Here's the working code:
std::vector<double>::iterator it;
std::vector<double> data(100);
RandomGenerator<double> g;
for(it = data.begin(); it != data.end(); ++it)
{
*it = g.GetGaussian();
}
This works fine. So I thought I could use std::generate to accomplish
the same thing. I've tried lots of combinations, but this is the one
I thought most likely to work:
std::generate(data.begin(), data.end(),
std::bind1st(std::mem_fun(&RandomGenerator<double>::GetGaussian),
&g));
I thought this should work because GetGaussian effectively has one
parameter, namely the object it's being invoked on. However, when I
try to compile this, I get a slew of errors about first_argument_type
and second_argument_type not being defined.
Any thoughts?
Thanks in advance,
Bill
about at wits end. Here's the working code:
std::vector<double>::iterator it;
std::vector<double> data(100);
RandomGenerator<double> g;
for(it = data.begin(); it != data.end(); ++it)
{
*it = g.GetGaussian();
}
This works fine. So I thought I could use std::generate to accomplish
the same thing. I've tried lots of combinations, but this is the one
I thought most likely to work:
std::generate(data.begin(), data.end(),
std::bind1st(std::mem_fun(&RandomGenerator<double>::GetGaussian),
&g));
I thought this should work because GetGaussian effectively has one
parameter, namely the object it's being invoked on. However, when I
try to compile this, I get a slew of errors about first_argument_type
and second_argument_type not being defined.
Any thoughts?
Thanks in advance,
Bill