Re: Declaring overloads (and template functions).

"Roman Yakovenko" <[email protected]>
Newsgroups gmane.comp.lib.boost.langbinding
Message-ID <[email protected]>
On 7/26/07, Rene Rivera <[email protected]> wrote:
> 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.

I could be wrong but you can check this with boost::function library.
http://boost.org/doc/html/function/tutorial.html#id1186900 .
If that library can do this, than you can do it too.


-- 
Roman Yakovenko
C++ Python language binding
http://www.language-binding.net/

-------------------------------------------------------------------------
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.