Report a bug
If you spot a problem with this page, click here to create a Bugzilla issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page. Requires a signed-in GitHub account. This works well for small changes. If you'd like to make larger changes you may want to consider using a local clone.
Add enum E(T) = expression; eponymous template support
Version | 1 |
Created | 2013-06-24 |
Status | Implemented |
Last modified | 2013-06-24 |
Author | |
Breaks | Nothing (extension) |
Load | Design Details |
Abstract
This pattern has become quite common in D:
template isIntegral(T) {
enum isIntegral = is(T : long) || is(T : ulong) || ...;
}
Analogously to struct S(T), the enum manifest constant could be written as:
enum isIntegral(T) = is(T : long) || is(T : ulong) || ...;
This is a natural fit for D. It does not break any existing code, and is simple to implement - it’s just a rewrite in the parser.
Rationale
The pattern is common, and a bit awkward. It’s worth supporting the new syntactic sugar.
Copyright
This document has been placed in the Public Domain.
Page generated on April 28, 2016 07:50:05