digitalmars.D.bugs - [Issue 1997] New: Better type inference for templated types
- d-bugmail puremagic.com (30/30) Apr 15 2008 http://d.puremagic.com/issues/show_bug.cgi?id=1997
- d-bugmail puremagic.com (34/34) Mar 10 2010 http://d.puremagic.com/issues/show_bug.cgi?id=1997
- d-bugmail puremagic.com (18/18) Sep 16 2011 http://d.puremagic.com/issues/show_bug.cgi?id=1997
http://d.puremagic.com/issues/show_bug.cgi?id=1997 Summary: Better type inference for templated types Product: D Version: unspecified Platform: All OS/Version: All Status: NEW Severity: enhancement Priority: P2 Component: DMD AssignedTo: bugzilla digitalmars.com ReportedBy: simen.kjaras gmail.com In the following code, a shortcoming of current type inference is pointed out: struct foo(T) { T data; static foo!(T) opCall(T t) { foo!(T) result; result.data = t; return result; } } auto f = foo(4); The line with 'f = foo(4)' gives a template instantiation error, while it should be possible for the compiler to infer the template parameters from the call. auto g = foo!(int)(4); This works, but is nowhere near as pretty. --
Apr 15 2008
http://d.puremagic.com/issues/show_bug.cgi?id=1997 Jesse Phillips <Jesse.K.Phillips+D gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |Jesse.K.Phillips+D gmail.co | |m Version|unspecified |2.041 08:46:35 PST --- DMD includes private methods when it tries to match for type inference even though the private function is not available. .\test.d(10): Error: template bar.Bar(T) does not match any function template declaration .\test.d(10): Error: template bar.Bar(T) cannot deduce template function from argument types !()(void delegate()) ------------------ module bar; import foo; void Bar(T)(void delegate(T) call) { } void main() { auto foo = new Foo(); Bar(&foo.fish); } ------------------ module foo; class Foo { private void fish() { } public void fish(string color) { } } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Mar 10 2010
http://d.puremagic.com/issues/show_bug.cgi?id=1997 PDT --- It is worth noting here that the workaround is to use a free function: struct Foo( T ) { T data; this( T value ) { data = value; } } Foo!T foo( T )( T value ) { return Foo!T( value ); } void main( ) { foo( 4 ); } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Sep 16 2011