Bug 2597 – auto return doesn't work for a variety of cases
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Linux
Creation time
2009-01-20T23:24:00Z
Last change time
2015-06-09T05:14:40Z
Assigned to
bugzilla
Creator
andrei
Comments
Comment #0 by andrei — 2009-01-20T23:24:25Z
Type deduction for function value return type doesn't work for member functions of templates, e.g.:
struct S(T)
{
auto a(U)(U x) { return 5; }
auto b(T x) { return 5; }
auto c() { return 5; }
}
doesn't work (a is fine, b and c are not although all three are function templates). I'm thinking also non-templates could be helped by auto:
auto d(T)(T x) { return 5; }
auto e(int x) { return 5; }
d works, e doesn't. Should it?
Comment #1 by jarrett.billingsley — 2009-01-21T08:02:40Z
(In reply to comment #0)
> auto d(T)(T x) { return 5; }
> auto e(int x) { return 5; }
>
> d works, e doesn't. Should it?
Of course it should. Why does this work:
auto e = (int x) { return 5; }
but not:
auto e(int x) { return 5; }
?
Wouldn't the two use.. more or less the exact same mechanism?