Boost logo

Boost :

From: Max Khesin (MKhesin_at_[hidden])
Date: 2004-04-30 12:56:10

I am refactoring code that looks something like this:

        if (op == LN::FILTER_IN || op == LN::FILTER_NOT_IN)
            where += handle_set_operation(column, type, format, op,
        else if (op == LN::FILTER_RANGE)
            where += handle_range_operation(column, type, format, op,
        else if (op == LN::FILTER_NULL || op == LN::FILTER_NOT_NULL)
            where += handle_null_operation(column, op);

This would obviously be handled better with a map of some sort (has to map
int to function). The problem here is that some functions have more
arguments than others, precluding the possibility of uniform type for the
function value of the map. I cannot just go and change the function sig to
include dummy values ('cause it's a dumb idea). This situation made me think
of boost.function/boost.bind, which allows to effectively shorten the
function parameter list by binding some of the args.

so given
int f(int a, int b)
    return a + b;

bind(f, _1, 5)(x);
is equivalent to
f(x, 5);

and by extension
bind(f, _1, _2, _0)(x, y, z)
would be equivalent to
f(x, y)

This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify the system manager. This message contains confidential information and is intended only for the individual named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail.

Boost list run by bdawes at, gregod at, cpdaniel at, john at