Boost logo

Boost :

From: Jonathan Turkanis (technews_at_[hidden])
Date: 2004-08-17 15:45:26

<Arturo_Cuebas_at_[hidden]> wrote in message
> The program below contains a compile error. Following the program
> will find the typical fix then my idea for a library that
> a syntactically prettier fix.


> struct C
> {
> void F(char, char){}
> void F(int, int){}
> void F(char, int){}
> void F(char){}
> };
> int main()
> {
> C o;
> bind(
> C::F, // error: which C::F?
> &o, _1);
> }
> Typical solution:
> bind(static_cast<void (C::*)(char)>(C::F), &o, _1);


> Here's my idea. If we had these:


> ...etc; the bind call would look like this:
> bind(resolve_cast1<char>(C::F), &o, _1);


> Is this worth the trouble?

I really like the idea. The main advantage is that you don't have to
repeat the class name, which may be long. E.g.

   void (symmetric_filter_adapter_impl::*close) () =

> Is it possible to implement a form without a number appended?

I can do it with this syntax:


using function types as in Boost.Function. Your version would be the
'portable syntax'.

> Is there a name better than resolve_cast?

Sounds okay to me.

> This was tested only in VC7.1.

You need to add &'s to former member function pointers. Otherwise it
looks okay to me. My version works on VC7.1, Como 4.3.3 and GCC 3.2.
I'll post it if there's interest.


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