Address of overloaded functions
Tyro[17]
ridimz at yahoo.com
Wed Jul 3 16:31:39 PDT 2013
On 7/3/13 12:52 PM, Artur Skawina wrote:
> import std.stdio;
>
> void foo(int a){ writeln("overload int"); }
> void foo(long b){ writeln("overload long"); }
>
> auto pickOverload(alias FP, A...)() @property { typeof(FP(A.init)) function(A) fp = &FP; return fp;}
>
> void main()
> {
> auto b = pickOverload!(foo, long);
> b(2);
> }
Often I see terse demonstrations of ingenious ways of doing things in
the language but am at a lost as with regards to under what
circumstances on would use such a feature. This happens to be one of
those cases. Could you provide a couple circumstances where this would
prove useful/handy?
Thanks,
--
Andrew Edwards
--------------------
http://www.akeron.co
auto getAddress() {
string location = "@", period = ".";
return ("info" ~ location ~ "afidem" ~ period ~ "org");
}
More information about the Digitalmars-d-learn
mailing list