Flag proposal
Daniel Murphy
yebblies at nospamgmail.com
Sun Jun 12 05:33:00 PDT 2011
"Timon Gehr" <timon.gehr at gmx.ch> wrote in message
news:it0oee$ehu$1 at digitalmars.com...
>
> What about allowing anonymous enums in parameter lists? Unfortunately that
> would
> be a language feature. :)
>
> T someAlgorithm(..., enum {unsorted, sorted} sortOutput);
>
> To call: someAlgorithm(..., sorted); / someAlgorithm(..., unsorted);
>
Wow - I actually really like this! It would provide an even _better_
solution than named arguments for this type of thing!
The best part is that it could degrade to the enum's base type when taking a
function pointer, mangling the function's name and even inside the
function's body!
void myfunction(enum : int { option1, option2, option3 } options)
{
static assert(is(typeof(options) == int));
}
static assert(is(typeof(&myfunction) == void function(int));
myfunction(option2);
More information about the Digitalmars-d
mailing list