STL bind1st counterpart for unary function
From: Fred Ma (fma_at_doe.carleton.ca)
Date: 02/05/04
- Next message: Rolf Magnus: "Re: c++ wrapper class for zlib ?"
- Previous message: Richard Bos: "Re: Any C/C++ LINT type checking recomendations"
- Next in thread: Rolf Magnus: "Re: STL bind1st counterpart for unary function"
- Reply: Rolf Magnus: "Re: STL bind1st counterpart for unary function"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 5 Feb 2004 09:33:46 GMT
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
-- Fred Ma Dept. of Electronics, Carleton University 1125 Colonel By Drive, Ottawa, Ontario Canada, K1S 5B6
- Next message: Rolf Magnus: "Re: c++ wrapper class for zlib ?"
- Previous message: Richard Bos: "Re: Any C/C++ LINT type checking recomendations"
- Next in thread: Rolf Magnus: "Re: STL bind1st counterpart for unary function"
- Reply: Rolf Magnus: "Re: STL bind1st counterpart for unary function"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|