On Thu, 08 Mar 2012 01:07:08 -0500, James Miller <ja...@aatch.net> wrote:
On 8 March 2012 18:38, Tyler Jameson Little <beatgam...@gmail.com> wrote:
I would like to do something like this:
version (linux || BSD) {
// do something...
} else {
version (Windows) {
// do something else
} else {
// do something else
assert(false, "Unsupported operating system");
}
}
The only way I've been able to do this, is by splitting up the two
versions
and repeat code.
Is there a better way to do this? A static if can do this, so is there
a way
that I can use a static if somehow?
I don't think there is an 'elseif' for versions, probably because you
are normally checking mutually exclusive version descriptions.
Otherwise, its probably a good idea to keep the syntax as is, since it
stops people from abusing the mechanic.
Noting that there actually isn't an elseif keyword for if either, of
course there is the same construct for version:
// if
if(cond1)
{}
else if(cond2)
{}
// version
version(version1)
{}
else version(version2)
{}
-Steve