Template method and type resolution of return type
monarch_dodra via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sun Apr 20 01:28:06 PDT 2014
On Sunday, 20 April 2014 at 07:52:08 UTC, matovitch wrote:
>
> struct S
> {
> ubyte get() { return 0 ; }
> float get() { return 0.; }
> }
>
> void main()
> {
> S s;
> float x = s.get(); // does'nt know which overload, does'nt
> compile.
> }
What I do find interesting though, is that you are allowed to
write the overload, whereas C++ would outright block you for
ambiguity "at the source".
This means that with proper meta magic eg
`__traits(getOverloadSet, S, "get")`, you could, *manually*
resolve the ambiguity yourself.
More information about the Digitalmars-d-learn
mailing list