Bug 14359 – [SDC] Allow inferring template parameter from type of template value parameter

Status
NEW
Severity
enhancement
Priority
P4
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2015-03-28T16:50:15Z
Last change time
2024-12-13T18:41:32Z
Keywords
rejects-valid
Assigned to
No Owner
Creator
Shammah Chancellor
Moved to GitHub: dmd#18963 →

Comments

Comment #0 by shammah.chancellor — 2015-03-28T16:50:15Z
``` > dmd test0154.d test0154.d(6): Error: undefined identifier T ``` ```test0154.d //T compiles:yes //T has-passed:yes //T retval:25 // template value parameter auto foo(T U, T)() { return cast(int) (U + T.sizeof); } int main() { return foo!true() + foo!10() + foo!I(); } enum I = 5; ```
Comment #1 by k.hara.pg — 2015-03-29T04:56:15Z
How SDC works for following codes? auto foo(T u, T)() { return typeof(u).stringof; } pragma(msg, foo(1)); // T is deduced to int ... it's reasonable. pragma(msg, foo(1, int)); // typeof(1) is int by default, so it might be accepted pragma(msg, foo(1, long)); // typeof(u) will be long, or conflict happens? pragma(msg, foo(1, double)); // typeof(u) will be double, or conflict happens? pragma(msg, foo(1, string)); // definitely conflicts
Comment #2 by yebblies — 2015-04-11T06:29:44Z
Is this supposed to work? Change back to normal if so.
Comment #3 by yebblies — 2015-04-11T06:40:10Z
*** Issue 14362 has been marked as a duplicate of this issue. ***
Comment #4 by nick — 2018-11-30T12:57:20Z
*** Issue 17279 has been marked as a duplicate of this issue. ***
Comment #5 by robert.schadek — 2024-12-13T18:41:32Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/18963 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB