F
Fred Ma
Hello,
I have a random generator that takes a scaling factor as an
argument. Since it takes one argument, it is not a
generator in the sense defined by SGI's online STL
documentation. I'd like to use this as a generator in the
STL algorithm "generate". I know I have to change random
generator from its current implementation to make it
adaptable. But unlike the bind1st adapter, there isn't any
premade function adapter that reduces the arity of a unary
function by binding the argument to a constant. So I can't
use it in the STL generate algorithm without writing a
wrapper. It's not a big deal, but it's a bit of a waste to
write a wrapper just to fix the argument of the generator to
one constant value, and just to avoid rolling my own loop to
fill a container with random numbers. Of course I will
write my own one-line loop, but just out pedagogical
curiosity, is there a _simple_ way to use the STL generate
algorithm in this case, using only standardized libraries?
Fred
I have a random generator that takes a scaling factor as an
argument. Since it takes one argument, it is not a
generator in the sense defined by SGI's online STL
documentation. I'd like to use this as a generator in the
STL algorithm "generate". I know I have to change random
generator from its current implementation to make it
adaptable. But unlike the bind1st adapter, there isn't any
premade function adapter that reduces the arity of a unary
function by binding the argument to a constant. So I can't
use it in the STL generate algorithm without writing a
wrapper. It's not a big deal, but it's a bit of a waste to
write a wrapper just to fix the argument of the generator to
one constant value, and just to avoid rolling my own loop to
fill a container with random numbers. Of course I will
write my own one-line loop, but just out pedagogical
curiosity, is there a _simple_ way to use the STL generate
algorithm in this case, using only standardized libraries?
Fred