shorthand template and static conditionals?
Lars T. Kyllingstad
public at kyllingen.NOSPAMnet
Thu Jul 30 00:17:30 PDT 2009
Jeremie Pelletier wrote:
> Another suggestion would be to have the ?: syntax supported for static statements, as we're currently forced to use static ifs. It really adds a lot of code to templates for even simple conditions.
?: already works at compile time, at least in D2. I use it all the time.
template cat(string a, string b, bool addSpace)
{
enum string cat = a ~ (addSpace ? " " : "") ~ b;
}
static assert (cat!("foo", "bar", false) == "foobar");
static assert (cat!("foo", "bar", true) == "foo bar");
Is that what you meant?
-Lars
More information about the Digitalmars-d
mailing list