better compile-time messages for string functors

Christopher Wright dhasenan at gmail.com
Sat Jan 31 16:42:39 PST 2009


Andrei Alexandrescu wrote:
> Don wrote:
>> Not necessarily. Andrei can just add:
>>
>> static if(__traits(compiles, mixin(comp) )) {
>>   mixin(comp);
>> } else {
>>    // static assert is a bit broken,
>>    // better to do it this way to provide a backtrace.
>>    pragma(msg, "Bad predicate: " ~ comp);
>>    deliberate_error_message; // t
>> }
>>
>> into std.functional. Which will generate a very controlled error message.
>> (Doesn't work if the predicate contains mismatched parentheses, but 
>> that's fixable).
> 
> I tried the above and didn't quite work. The deliberate_error_message 
> would trigger an error even for valid expressions. What I have now is this:

Use a string mixin for deliberate_error_message.



More information about the Digitalmars-d mailing list