struct Yes in std.typecons

Peter Summerland p.summerland at gmail.com
Thu Nov 1 10:41:24 PDT 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



More information about the Digitalmars-d-learn mailing list