On 2011-06-11 09:05:52 -0400, "Steven Schveighoffer"
<[email protected]> said:
As far as the negation, I think we need one more layer of type:
struct FlagParam(string pname)
{
Flag!pname value;
alias value this;
this(Flag!pname x) { this.value = x }
FlagParam op???() const { return FlagParam(cast(Flag!pname)!value); }
}
BTW, is there a way to hook "!"? Maybe this won't work... The idea is
to have Yes.abc return FlagParam!"abc"(Flag!"abc".yes).
If you need to convert a bool to a Flag!"abc", you can do any of these:
func(expression ? Yes.abc : No.abc);
or
func(cast(Flag!"abc")expression);
or, with your proposal:
func(FlagParam!"abc"(expression));
None of this is very appealing, but I find the first is the most readable.
--
Michel Fortin
[email protected]
http://michelf.com/