[Issue 1528] [tdpl] overloading template and non-template functions
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Feb 27 06:29:47 PST 2013
http://d.puremagic.com/issues/show_bug.cgi?id=1528
--- Comment #15 from timon.gehr at gmx.ch 2013-02-27 06:29:43 PST ---
(In reply to comment #14)
> ...
>
> static assert(f6(1L) == 1);
> static assert(f6(ulong.max) == 2); // (a) ???
>
No match.
> ulong ul = runtime();
> static assert(f6(ul) == 2); // (b) ???
>
No match.
> How would these resolve?
>
> I am not really comfortable with the fact that a call can statically resolve to
> two different functions depending on the static information of the *value* of a
> parameter:
>
Well, that is how the language is specified.
int f8(byte){ return 1; }
int f8(long){ return 2; }
void main(){
static assert(f8(1)==1); // calls first
static assert(f8(256)==2); // calls second
int x=1;
f8(x); // calls second
}
> int f7(ubyte a) { return 1; }
> int f7(T)(T b) if (is(T : int)) { return 2; }
>
> void main(){
> static assert(f6(200u)==1); //Calls first
No, calls second.
> static assert(f6(400u)==2); //Calls second (!?)
>
Yes.
> //Run-time variable with TDPL-like range knowledge
> uint a = 400;
Knowledge lost here.
> static assert(f6(a) == 2); //Calls second ?
> a = 200;
Ditto.
> static assert(f6(a) == 1); //But now calls first !?
> }
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list