Thread overview |
---|
October 09, 2006 [Issue 415] New: conflicting template functions overloads | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=415 Summary: conflicting template functions overloads Product: D Version: 0.169 Platform: PC OS/Version: Linux Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: bugzilla@digitalmars.com ReportedBy: benoit@tionex.de void arraycopy( T )( T[] src, T[] trg, int length ){ } void main(){ char[] a, b; arraycopy( a, b, 1 ); //(1) arraycopy( a, b, a.length ); //(2) } I don't want to change the main() content: (2) causes an error because length is uint. if I change the signature of arraycopy to "( T[], T[], uint)", (1) causes an error. If I supply both variations, they conflict. They should not. -- |
October 10, 2006 [Issue 415] conflicting template functions overloads | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=415 davidl@126.com changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |FIXED -- |
October 10, 2006 [Issue 415] conflicting template functions overloads | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=415 davidl@126.com changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |golovanov_alexey@mail.ru ------- Comment #1 from davidl@126.com 2006-10-09 20:17 ------- void arraycopy( T,U )( T[] src, T[] trg, U length ){ static if (is(U: int)) //now uint ,int and other type can implicitly cast to //int can be processed { // do ur job here } } void main(){ char[] a, b; arraycopy( a, b, 1 ); //(1) arraycopy( a, b, a.length ); //(2) } -- |
October 10, 2006 [Issue 415] conflicting template functions overloads | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=415 davidl@126.com changed: What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |REOPENED Resolution|FIXED | ------- Comment #2 from davidl@126.com 2006-10-09 20:19 ------- ah, u mean the problem is they should not conflict... umm yep , they shouldn't conflict if they can't be implicitly cast to one type. -- |
October 10, 2006 [Issue 415] conflicting template functions overloads | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=415 ------- Comment #3 from davidl@126.com 2006-10-09 20:30 ------- umm, i think i should state that more clear, i guess the problem is dmd not doing enough distinguish check when the template in this collapsed form. actually if i write template arraycopy(T) { arraycopy(T[] a, T[] b, int length) arraycopy(T[] a, T[] b, uint length) } is ok but the main func in ur example need to modified, so that's not a good idea. -- |
October 16, 2006 [Issue 415] conflicting template functions overloads | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=415 ------- Comment #4 from brunodomedeiros+bugz@gmail.com 2006-10-16 09:21 ------- If I may, a more illustrative case: -------- void func(int a) { } void tfunc()(int a) { } void test() { func(cast(uint) 2); // OK tfunc!()(cast(uint) 2); // OK tfunc(cast(uint) 2); // IFTI breakage } -- |
November 21, 2006 [Issue 415] conflicting template functions overloads | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=415 bugzilla@digitalmars.com changed: What |Removed |Added ---------------------------------------------------------------------------- Status|REOPENED |RESOLVED Resolution| |INVALID ------- Comment #5 from bugzilla@digitalmars.com 2006-11-21 17:40 ------- The language is working as defined. All the examples have easy solutions. Let's take the last one: void tfunc()(int a) { } void test() { tfunc!()(cast(uint) 2); // OK tfunc(cast(uint) 2); // IFTI breakage } Fix: void tfunc(T)(T a) { } Or: void tfunc()(int a) { } void tfunc(dummy=void)(uint a) { } -- |
Copyright © 1999-2021 by the D Language Foundation