[C++-sig] Possible overload<> template for class members
Joel de Guzman
djowel at gmx.co.uk
Fri Dec 13 11:49:50 CET 2002
----- Original Message -----
From: "Joel de Guzman" <djowel at gmx.co.uk>
> ----- Original Message -----
> From: "Aleksey Gurtovoy" <agurtovoy at meta-comm.com>
>
>
> > Ralf W. Grosse-Kunstleve wrote:
> > > --- William Trenker <wtrenker at hotmail.com> wrote:
> > > > .def("show", overload<void,void>(), &Window::show)
> > > > .def("show", overload<void,const Window*>(), &Window.show)
> > >
> > > That looks just like my old "plan A" :-)
> > >
> > > > Is something like this even possible?
> > >
> > > David kept claiming the answer is no, because in C++ you cannot take
> > > the "address" of a family over overloaded functions. If Window.show
> > > has overloads the compiler has no way of knowing which one you mean
> > > if you just type &Window.show.
> >
> > Hmm, seems entirely possible to me:
> >
> [snip]
> >
> > Am I missing something?
>
> Cool Aleksey, cool! I think your scheme will work, AFAICT.
> Might need some workarounds on VC6 and CW7.2.
> Compiles on g++2.95, g++3.1, Comeau, intel and VC7.
>
> However, it still can't handle default arguments automatically :-(
> For instance:
>
> void show(int = 45, bool* = 0, char 'x') {}
>
> I still see no way to def this in one fell swoop. You still need
> three defs.
>
> ... Or am I missing something?
Furthermore, you can't def overloads with common arguments
automatically in one shot:
void show() {}
void show(int) {}
void show(int, bool*) {}
void show(int, bool*, char) {}
Oh well....
Anyway, it seems better than having to cast the function pointer
for overloads.
Cheers,
Joel de Guzman
joel at boost-consulting.com
http://www.boost-consulting.com
More information about the Cplusplus-sig
mailing list