[Issue 6921] New: Request for a 'static final switch' statement
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Nov 9 11:29:18 PST 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6921
Summary: Request for a 'static final switch' statement
Product: D
Version: unspecified
Platform: All
OS/Version: All
Status: NEW
Severity: enhancement
Priority: P2
Component: DMD
AssignedTo: nobody at puremagic.com
ReportedBy: ThatsGobbles at gmail.com
--- Comment #0 from Mark LeMoine <ThatsGobbles at gmail.com> 2011-11-09 11:28:40 PST ---
I've often come across cases where I find it'd be handy to have a different
constructor based on a passed-in template enum parameter:
enum Options {
Some, Many, All
}
class OptionManager(Options O) {
static if(O == Options.Some) {
alias TypeTuple!(int) TP;
}
else static if(O == Options.Some) {
alias TypeTuple!(int, int, int) TP;
}
else static if(O == Options.Some) {
alias TypeTuple!(int, int, int, int, int, int) TP;
}
else {
static assert(0);
}
public this(TP params) {
// ...
}
}
However, this necessitates a static if-else chain, as shown. It would be quite
handy to have a static final switch variant for cases like the above. Would
this be something easy to implement in the D language?
--
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