Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SDC] Allow inferring template parameter from type of template value parameter #18963

Open
dlangBugzillaToGithub opened this issue Mar 28, 2015 · 4 comments

Comments

@dlangBugzillaToGithub
Copy link

Shammah Chancellor reported this on 2015-03-28T16:50:15Z

Transferred from https://issues.dlang.org/show_bug.cgi?id=14359

CC List

  • ag0aep6g
  • yebblies
  • Yuxuan Shui

Description

```
> 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;
```
@dlangBugzillaToGithub
Copy link
Author

k.hara.pg commented on 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

@dlangBugzillaToGithub
Copy link
Author

yebblies commented on 2015-04-11T06:29:44Z

Is this supposed to work?  Change back to normal if so.

@dlangBugzillaToGithub
Copy link
Author

yebblies commented on 2015-04-11T06:40:10Z

*** Issue 14362 has been marked as a duplicate of this issue. ***

@dlangBugzillaToGithub
Copy link
Author

nick (@ntrel) commented on 2018-11-30T12:57:20Z

*** Issue 17279 has been marked as a duplicate of this issue. ***

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant