Select overload revisited

I was thinking about the overload resolution functions suggested a while back by Arturo Cuebas[1] and had no idea why the compiler needs to be told the number of parameters in the first place. So I took his code and removed the numbers from functions, and it worked (in gcc). I guess that it didn't work for him because of his compiler. Well, it almost worked. Sometimes there is more than the one function that fits the template parameters. So I kept the numbered overloads to be able to match them. It might be possible to get these to work without the number of parameters by making the compiler prefer overloads for functions with less parameters. I've attached a demo. Daniel [1] http://lists.boost.org/MailArchives/boost/msg69451.php

Daniel James <daniel@calamity.org.uk> wrote on 02/26/2005 10:38:06 AM:
I was thinking about the overload resolution functions suggested a while
back by
Funny: I just started revisiting this again too. I also figured out a way to not have to specify the arity - most of the time. I have some questions about your implementation but I'll wait to ask them until after I've gone home and tried a couple of things out on mine.

Daniel James wrote:
I was thinking about the overload resolution functions suggested a while back by Arturo Cuebas[1] and had no idea why the compiler needs to be told the number of parameters in the first place. So I took his code and removed the numbers from functions, and it worked (in gcc). I guess that it didn't work for him because of his compiler.
Funny, I thought we tried everything ;-)
Well, it almost worked. Sometimes there is more than the one function that fits the template parameters. So I kept the numbered overloads to be able to match them.
Could you give a general description of the types of cases that don't work? Jonathan

Daniel James <daniel@calamity.org.uk> wrote on 02/26/2005 10:38:06 AM: [snip]
TR (TC::* select_overload(TR (TC::* Func)(void), int = 0))(void) [snip] TR (TC::* select_overload(TR (TC::* Func)(TP), float = 0))(TP) [snip] TR (TC::* select_overload(TR (TC::* Func)(TP1, TP2), from_float = from_float(0)))(TP1, TP2) [snip] TR (* select_overload(TR (* Func)(void), int = 0))(void) [snip] TR (* select_overload(TR (* Func)(TP), float = 0))(TP) [snip] TR (* select_overload(TR (* Func)(TP1, TP2), from_float = from_float(0))) (TP1, TP2)
What's the purpose of the default parameters in the versions of select_overload above? I went ahead and uploaded my boostified implementation to the Boost Sandbox File Vault: http://tinyurl.com/6srac. So far, it’s only been tested on VC7.1/Windows. I plan on trying it out on GCC and Linux at some point. Arturo_Cuebas@bpmicro.com wrote on 02/28/2005 02:18:16 PM:
Funny: I just started revisiting this again too. I also figured out a way to not have to specify the arity - most of the time.
Please disregard what I said here. It turns out that this extra "thing" I was doing made no difference.

Arturo_Cuebas@bpmicro.com wrote:
What's the purpose of the default parameters in the versions of select_overload above?
Ooops, I attached the wrong version of the file - I was just experimenting with something that didn't work. Those extra parameters shouldn't have been there. I'll look for the right version later - but it was basically your version but with both numbered and unnumbered function names. Nothing clever at all. Daniel
participants (3)
-
Arturo_Cuebas@bpmicro.com
-
Daniel James
-
Jonathan Turkanis