www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - what's the point of function template declarations if they can't be

reply Timothee Cour <thelastmammoth gmail.com> writes:
```
void fun_bad3(T)(T a);  // declaration [1]
void fun_bad3(T)(T a){};  // definition [2]
void test(){
  fun_bad3(1);
}
```
Error: test_all.fun_bad3 called with argument types (int) matches both:
main.d(11):     test_all.fun_bad3!int.fun_bad3(int a)
and:
main.d(12):     test_all.fun_bad3!int.fun_bad3(int a)

should [1] be allowed? compler doens't allow defining it afterwards in
[2] (unlike function definitions, and, well, modulo this regression
https://issues.dlang.org/show_bug.cgi?id=18393)
Feb 07 2018
parent Jacob Carlborg <doob me.com> writes:
On 2018-02-07 22:39, Timothee Cour wrote:
 ```
 void fun_bad3(T)(T a);  // declaration [1]
 void fun_bad3(T)(T a){};  // definition [2]
 void test(){
    fun_bad3(1);
 }
 ```
 Error: test_all.fun_bad3 called with argument types (int) matches both:
 main.d(11):     test_all.fun_bad3!int.fun_bad3(int a)
 and:
 main.d(12):     test_all.fun_bad3!int.fun_bad3(int a)
 
 should [1] be allowed? compler doens't allow defining it afterwards in
 [2] (unlike function definitions, and, well, modulo this regression
 https://issues.dlang.org/show_bug.cgi?id=18393)
Perhaps if it's defined in another file. -- /Jacob Carlborg
Feb 08 2018