Declaring overloads (and template functions).

Rene Rivera <[email protected]>
Newsgroups gmane.comp.lib.boost.langbinding
Organization Redshift Software, Inc.
Message-ID <[email protected]>
First, yes, I'm still working on a development plan which is 
unexpectedly rather difficult because of the lack of 
implementation/desing docs for the existing code :-( Anyway I'm going to 
start posting questions as I both run into them, and as I remember...

One item I've run into many times now, I've answered the same question 
in IRC a few times, is how overloads are declared. Most programmers seem 
unfamiliar with the function pointer cast method of obtaining a specific 
function, either a specific overload or function template instance. 
Taking the Luabind example (since Luabind is closer to what we want 
Langbinding to model):

===C++
struct A
{
     void f(int);
     void f(int, int);
};

class_<A>()
     .def("f", (void(A::*)(int))&A::f)
===

My idea is that since we have a precedent for decorating the functions, 
in the form of "constructor<T>()", we can use a similar decoration to 
make the syntax obvious, and to remove some of the repetition. Something 
like:

===C++
class_<A>()
     .def("f", overload<void(int)>(&A::f))
===

Though, I'm not sure if one can make such an "overload<>()" function 
smart enough to automatically turn the bare function type into the 
corresponding member function pointer type.


-- 
-- Grafik - Don't Assume Anything
-- Redshift Software, Inc. - http://redshift-software.com
-- rrivera/acm.org - grafik/redshift-software.com
-- 102708583/icq - grafikrobot/aim - grafikrobot/yahoo

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.