[Issue 2257] Template value parameters behave like alias parameters
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Nov 6 22:23:36 PST 2009
http://d.puremagic.com/issues/show_bug.cgi?id=2257
--- Comment #3 from Rob Jacques <sandford at jhu.edu> 2009-11-06 22:23:35 PST ---
(In reply to comment #2)
> This issue causes major issues with Nd-array and Small Vector implementations,
> as the incorrect type signatures play havoc with other templated functions.
> Here is another test case illustrating the problem:
>
> import std.stdio;
> struct Matrix(T,size_t D) {
> Matrix!(U,D) foo(U)(U v) { return Matrix!(U,D)(); }
> }
>
> void main() {
> real r;
> size_t d = 2;
> Matrix!(float,2) m;
> writeln(typeof( m.foo(r) ).stringof); //writes Matrix(float,D)
> Matrix!(float,d) n;
> writeln(typeof( n ).stringof); //writes Matrix(float,d)
> }
A Mitigation for the above example:
Matrix!(U,D+0) foo(U)(U v) { return Matrix!(U,D)(); }
changes "Matrix(float,D)" to "writes Matrix(float,2u)"
However, the original template type is still distinct: Matrix(float,2)
Also, it appears that even though D is unsigned, the template type is signed.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list