[Issue 6924] New: An alias this problem to implement a Typedef
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Nov 9 20:03:56 PST 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6924
Summary: An alias this problem to implement a Typedef
Product: D
Version: D2
Platform: x86
OS/Version: Windows
Status: NEW
Severity: normal
Priority: P2
Component: DMD
AssignedTo: nobody at puremagic.com
ReportedBy: bearophile_hugs at eml.cc
--- Comment #0 from bearophile_hugs at eml.cc 2011-11-09 20:03:18 PST ---
I find typedef useful still. While trying to create something like a typedef
using a struct with "alias this", I have found this problem:
struct Typedef(T) {
T data;
alias data this;
}
alias int[] TA1;
typedef int[] TA2;
alias Typedef!(int[]) TA3;
immutable TA1 a1;
immutable TA2 a2;
TA3 a3a;
immutable TA3 a3b;
static this() {
a1 = [1, 2, 3]; // OK
a2 = [1, 2, 3]; // OK
a3a = [1, 2, 3]; // OK
a3b = [1, 2, 3]; // line 16, error
}
void main() {}
DMD 2.057beta gives:
test.d(16): Error: cannot implicitly convert expression ([1,2,3]) of type int[]
to immutable(Typedef!(int[]))
--
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