handful and interval

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Sun Sep 2 07:22:20 PDT 2012


I'd like to add a simple function to std called "handful". It would 
return a small, read-only set of which main facility is membership test:

string a = "class";
if (a in handful("struct", "class", "union"))
{
     ...
}

Would it be generally useful, and if so what module does it belong to?

Same question about "interval", which is a fair amount more interesting 
if done right. An interval is a pair of values from a type that supports 
inequality comparison. It would have a variety of interval-specific 
operations, of which this would probably be quite popular:

int x;
...
if (x in interval(1, 2))
{
     ...
}


Destroy,

Andrei


More information about the Digitalmars-d mailing list