D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 10919 - typeof should accept types
Summary: typeof should accept types
Status: RESOLVED INVALID
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P4 enhancement
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-08-28 23:52 UTC by Jacob Carlborg
Modified: 2023-03-27 12:37 UTC (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Jacob Carlborg 2013-08-28 23:52:24 UTC
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 Don 2013-08-30 00:53:32 UTC
See bug 1341.
Comment 2 timon.gehr 2013-08-30 17:38:27 UTC
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 Temtaime 2013-08-31 01:45:50 UTC
I'm agree with Timon.
Comment 4 Johannes Loher 2018-05-05 22:33:17 UTC
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?