vector of doubles (division)
-
Thanks Ash. I implemented the code, but it is giving many errors, the first being:
error C2825: '_Fn2': must be a class or namespace when followed by '::'
and the 2nd:
error C2039: 'first_argument_type' : is not a member of '`global namespace''
Ooops, forgot to add in the bit of special sauce to convert the binary function pointer to a function object:
std::transform( input.begin(), input.end(), output.begin(), std::bind2nd( std::ptr_fun( op_divide ), 5 ) ) );
What you've got is a function that takes two arguments. The std::ptr_fun function returns a function object, the function call operator of which passes the arguments to the contained function. The std::bind2nd returns another function object: - the function call operator takes 1 parameter - the constructor of the object stores another parameter - the function call operator passes the 1 parameter and the stored parameter through to the contained binary function object which passes them through to the contained function pointer. Arrrgggghhhhh... I want me Lambda's back! Cheers, Ash PS: That's as clear as mud, I'll try and clean it up later
-
Ooops, forgot to add in the bit of special sauce to convert the binary function pointer to a function object:
std::transform( input.begin(), input.end(), output.begin(), std::bind2nd( std::ptr_fun( op_divide ), 5 ) ) );
What you've got is a function that takes two arguments. The std::ptr_fun function returns a function object, the function call operator of which passes the arguments to the contained function. The std::bind2nd returns another function object: - the function call operator takes 1 parameter - the constructor of the object stores another parameter - the function call operator passes the 1 parameter and the stored parameter through to the contained binary function object which passes them through to the contained function pointer. Arrrgggghhhhh... I want me Lambda's back! Cheers, Ash PS: That's as clear as mud, I'll try and clean it up later