...without having to loop over the enum? writeln( test( valid_value ) ); //prints true
Since `value` is known only at run time, some checks need to be performed at run time anyway. One way of doing it without iterating over all variants is to create a static hash table
bool[string] valid_strings;and populate it in static constructor, then in your function you can just write
if (value in valid_strings) ...