KeyType, ValueType traits for hashes

bearophile bearophileHUGS at lycos.com
Tue Jan 24 10:49:35 PST 2012


Mantis:

> Of course, most likely that user already did type check, but if not, 
> this will give less cryptic error:
> 
> Error: static assert "Not associative array: int"
> instantiated from here: KeyType!(int)
> 
> , instead of:
> 
> Error: template instance KeyType!(int) KeyType!(int) does not match 
> template declaration KeyType(AA) if (isAssociativeArray!(AA))

It's a tradeoff. Your custom error message is more readable, but the failure at the template constraint causes a error line at the instantiation point. Sadly I think there is no solution that solves both problems  (we have stack traces for templates, but...).

Bye,
bearophile


More information about the Digitalmars-d-learn mailing list