Boost logo

Boost Users :

Subject: Re: [Boost-users] Bimap compare function
From: Nathan Ridge (zeratul976_at_[hidden])
Date: 2012-05-04 23:38:28


> I noticed that the comparator for a bimap can only be a Functor Type.
> It does not appear that I can pass a function object or a function
> pointer, as a STL Set would allow. Is this correct or did I miss
> something. For my application I could really use the ability to pass in
> comparator which is decided at runtime. Does anyone have any
> suggestions on a work around?

I'm not familiar with bimap, but is there a reason you can't wrap a
function pointer (that can change at runtime) in a functor? Something
like:

typedef int (*function_type)(int);

struct my_functor
{
    function_type f;  // change this at runtime
   
    int operator()(int i)
    {
        return f(i);
    }
};

Regards,
Nate
                                               


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net