Bug 380 – cannot use typeof(*this) in a static context

Status
RESOLVED
Resolution
FIXED
Severity
minor
Priority
P3
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
Windows
Creation time
2006-09-27T12:21:00Z
Last change time
2014-02-15T13:20:40Z
Keywords
rejects-valid
Assigned to
bugzilla
Creator
h3r3tic

Comments

Comment #0 by h3r3tic — 2006-09-27T12:21:58Z
struct Foo { alias typeof(*this) ThisType; } > 'this' is only allowed in non-static member functions > can only * a pointer, not a 'int' workaround: struct Foo { alias typeof(*typeof(this).init) ThisType; static assert (is(Foo == ThisType)); }
Comment #1 by thomas-dloop — 2006-09-29T02:05:36Z
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 [email protected] schrieb am 2006-09-27: > http://d.puremagic.com/issues/show_bug.cgi?id=380 > struct Foo { > alias typeof(*this) ThisType; > } > > >> 'this' is only allowed in non-static member functions >> can only * a pointer, not a 'int' > > > > workaround: > > struct Foo { > alias typeof(*typeof(this).init) ThisType; > static assert (is(Foo == ThisType)); > } Added to DStress as http://dstress.kuehne.cn/compile/t/typeof_10_A.d http://dstress.kuehne.cn/compile/t/typeof_10_B.d http://dstress.kuehne.cn/compile/t/typeof_10_C.d http://dstress.kuehne.cn/compile/t/typeof_10_D.d Thomas -----BEGIN PGP SIGNATURE----- iD8DBQFFHDPELK5blCcjpWoRAqm+AJ4jqtlQEQkV9fgRzRJXIiHDmaPcewCdHewk 7VoXDtrrI5FWYnS+LQgrKZ8= =rMNb -----END PGP SIGNATURE-----
Comment #2 by bugzilla — 2006-11-25T03:51:37Z
Fixed DMD 0.175