www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - struct Yes in std.typecons

reply "Peter Summerland" <p.summerland gmail.com> writes:
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
Nov 01 2012
parent =?UTF-8?B?QWxpIMOHZWhyZWxp?= <acehreli yahoo.com> writes:
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 

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
Nov 01 2012