digitalmars.D.learn - address of overloaded function
- Freddy (11/11) Sep 30 2015 How do you take the address of a specific overloaded function.
- Adam D. Ruppe (4/6) Sep 30 2015 You can write a helper function that uses __traits(getOverloads)
- Jacob Carlborg (11/22) Oct 01 2015 Not sure why that doesn't work. This works:
How do you take the address of a specific overloaded function.
This won't compile
---
import std.range;
void main()
{
ForwardAssignable!int range;
int delegate() property get = &range.front;
void delegate(int) property set = &range.front;
}
---
Sep 30 2015
On Wednesday, 30 September 2015 at 22:48:03 UTC, Freddy wrote:How do you take the address of a specific overloaded function. This won't compileYou can write a helper function that uses __traits(getOverloads) and searches them for the right signature: http://dlang.org/traits.html#getOverloads
Sep 30 2015
On 2015-10-01 00:48, Freddy wrote:
How do you take the address of a specific overloaded function. This
won't compile
---
import std.range;
void main()
{
ForwardAssignable!int range;
int delegate() property get = &range.front;
void delegate(int) property set = &range.front;
}
---
Not sure why that doesn't work. This works:
int foo () { return 0; }
void foo (int) {}
void main()
{
int function () a = &foo;
void function (int) b = &foo;
}
--
/Jacob Carlborg
Oct 01 2015









Adam D. Ruppe <destructionator gmail.com> 