Bug 10919 – typeof should accept types

Status
RESOLVED
Resolution
INVALID
Severity
enhancement
Priority
P4
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-08-28T23:52:24Z
Last change time
2023-03-27T12:37:53Z
Assigned to
No Owner
Creator
Jacob Carlborg

Comments

Comment #0 by doob — 2013-08-28T23:52:24Z
Currently typeof only accepts expressions. I think it would be useful if typeof accepts types as well and just evaluate to the type given. This will make metaprogramming simpler. void foo (alias T) () { alias U = typeof(T); } foo!(3); // ok foo!(Object); // error, Object is not an expression
Comment #1 by clugdbug — 2013-08-30T00:53:32Z
See bug 1341.
Comment #2 by timon.gehr — 2013-08-30T17:38:27Z
This enhancement does not make any sense. int is not an int, it is a type. 0 is an int. A helper template can be used if an expression is desired that behaves in this way.
Comment #3 by temtaime — 2013-08-31T01:45:50Z
I'm agree with Timon.
Comment #4 by johannes.loher — 2018-05-05T22:33:17Z
It has been a long time since this has seen any attention, but I also agree with Timon. How should we go forward with this one? I highly doubt, it will ever be implemented and if so, it might need a DIP?