Boost logo

Boost :

Subject: Re: [boost] [bind] Function call operator is a template?!
From: Andy Venikov (avenikov_at_[hidden])
Date: 2009-12-16 22:18:39


OvermindDL1 wrote:
> On Wed, Dec 16, 2009 at 3:56 PM, Mathias Gaunard
> <mathias.gaunard_at_[hidden]> wrote:
>> Andy Venikov a écrit :
>>
>>> I'm not going to debate whether it's right or wrong, but I'm still curious
>>> - why did it have to be a template? When bind() is called it already has all
>>> the information about the function's signature
>> Not in the general case.
>> For function pointers or member function pointers, I suppose it is the case
>> though.
>
> struct myFunction
> {
> int operator()(char c, int i){...}
> int operator()(char c, std::string s){...}
> int operator()(char c, float f){...}
> }
>
> auto b = bind(myFunction, 42, _1);
>
> See why the template is useful now?

Well, returning a functor that had three overloaded operator()s one
taking and int, another taking a string and third taking a float would
be a nice solution.

It's just probably impossible to implement...
Hence templates...


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk