I have a "variation" of "unaryFun" that I name "unaryProp" that,
basically, doesn't require to specify "a." at the beginning of
the expression.
template unaryProp(alias propName)
{
static assert(is(typeof(propName) : string), "Sorry, propName
must be an string");
auto unaryProp(ElementType)(auto ref ElementType a)
{
return mixin("a." ~ propName);
}
}
assert( "hello".unaryProp!"length" == 5 );
Problem is I need to check that "propName" is a valid property
name at compile time
i.e. checking this Regex expression
`^[a-zA-Z_]*[a-zA-Z0-9_]*[a-zA-Z][a-zA-Z0-9_]*$`
Is there any way to check a regular expression at compile time?