November 01, 2012
The docs say:

Convenience names that allow using e.g. yes!"encryption" instead of Flag!"encryption".yes and no!"encryption" instead of Flag!"encryption".no.

I could not get yes!"encription" to work. But "Yes.encription" does. Are the docs out of date? Am I missing something? E.g.,

module yes_no_flag;

import std.stdio, std.typecons;

void retval(Flag!"encryption" v)
{
  if (v)
    writeln("Encryption");
  else
    writeln("Open");
}

void main()
{
  retval(Flag!"encryption".yes);
  retval(Flag!"encryption".no);
  retval(Yes.encryption);

  // retval(yes!"encryption");
  // Error: template instance yes!("encryption") template 'yes' is not
  // defined, did you mean Yes?
}


$> rdmd yes_no_flag.d
Encryption
Open
Encryption

November 01, 2012
On 11/01/2012 10:41 AM, Peter Summerland wrote:
> The docs say:
>
> Convenience names that allow using e.g. yes!"encryption" instead of
> Flag!"encryption".yes and no!"encryption" instead of Flag!"encryption".no.

The documentation is wrong.

Please either file a bug report or click the "Improve this page" button on that page to submit a pull request automatically. :) (I have never tried it myself though.)

Ali

Top | Discussion index | About this forum | D home