G
Giovanni Gherdovich
Hello,
as you know the algorithm std::accumulate in the
version
template<class In, class T, class BinOp>
T accumulate(In first, In last, T init, BinOp op)
{
while(first != last) init = op(init,*first++);
return init;
}
(from the header <numeric>) requires a binary function
as third argument.
Well, consider if I have a function object like this
struct some_operation
{
double operator()(double x, double y, double z)
{
return sin( pow(x*y,2) * z); // or any operation you like
}
}
I would like to bind, say, the first argument x to
a fixed value, then make a binary function out of my
ternary function some_operation, and provide it to
the algorithm std::accumulate.
Is there any standard way to do such binding?
I know the function adapters std::bind1st and std::bind2nd,
but thay work only for binary functions and yeld unary
functions...
Is there any way to use these two binders to build
more general binders?
Best regards,
Giovanni Gh.
as you know the algorithm std::accumulate in the
version
template<class In, class T, class BinOp>
T accumulate(In first, In last, T init, BinOp op)
{
while(first != last) init = op(init,*first++);
return init;
}
(from the header <numeric>) requires a binary function
as third argument.
Well, consider if I have a function object like this
struct some_operation
{
double operator()(double x, double y, double z)
{
return sin( pow(x*y,2) * z); // or any operation you like
}
}
I would like to bind, say, the first argument x to
a fixed value, then make a binary function out of my
ternary function some_operation, and provide it to
the algorithm std::accumulate.
Is there any standard way to do such binding?
I know the function adapters std::bind1st and std::bind2nd,
but thay work only for binary functions and yeld unary
functions...
Is there any way to use these two binders to build
more general binders?
Best regards,
Giovanni Gh.