D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 14359 - [SDC] Allow inferring template parameter from type of template value parameter
Summary: [SDC] Allow inferring template parameter from type of template value parameter
Status: NEW
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P4 enhancement
Assignee: No Owner
URL:
Keywords: rejects-valid
: 14362 17279 (view as issue list)
Depends on:
Blocks:
 
Reported: 2015-03-28 16:50 UTC by Shammah Chancellor
Modified: 2024-12-13 18:41 UTC (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Shammah Chancellor 2015-03-28 16:50:15 UTC
```
> 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 Kenji Hara 2015-03-29 04:56:15 UTC
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 yebblies 2015-04-11 06:29:44 UTC
Is this supposed to work?  Change back to normal if so.
Comment 3 yebblies 2015-04-11 06:40:10 UTC
*** Issue 14362 has been marked as a duplicate of this issue. ***
Comment 4 Nick Treleaven 2018-11-30 12:57:20 UTC
*** Issue 17279 has been marked as a duplicate of this issue. ***
Comment 5 dlangBugzillaToGithub 2024-12-13 18:41:32 UTC
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