String manipulation

Kagamin via Digitalmars-d digitalmars-d at puremagic.com
Fri Oct 23 00:57:13 PDT 2015


I think, it's more a problem with type inference, which is either 
exact match or nothing. I once had an idea of customized type 
inference, which is able to replace the matched type in the 
process (concepts probably can't do that, do they?), it also 
allows more constrained type inference than auto, which would 
result in a more readable code like `InputRange!int r = get();`. 
But as it's likely a complex feature and language is stabilized, 
I didn't bother to write a DIP.

@inference
template PseudoString(T)
{
   static if(__traits(compiles, string s=T.init))
     alias PseudoString=string;
   else
     alias PseudoString=NoMatch;
}

//signature becomes (string path) - type was inferred
bool isDir()(PseudoString path)
{
}


More information about the Digitalmars-d mailing list