Solution

Aziz K. aziz.kerim at gmail.com
Fri Dec 14 04:47:40 PST 2007


I thought about this issue a little bit before I went to sleep yesterday.  
It just occurred to me that a pragma statement would be perfect to solve  
this problem. Especially since it wouldn't require any modifications to a  
D parser.

struct S(T)
{
   static if(isFloatingPoint!(T))
   {
     /*...*/
   }
   /* other tests */	
   else
     pragma(fail_instantiation);
}

With this statement we can give a hint to the compiler to abort  
instantiation and try other (specialized) templates.
The question now is which identifier would be a good, descriptive and  
concise one.

.) fail_instantiation // good one, but too long?
.) fail_i11n // shortened similar to i18n/internationalization
.) fail // sounds too general and may conflict with possible future uses.
.) substitution_failure // a bit too long?
.) instantiation_failure // ditto
.) iFail // *rolls eyes*
.) stop_it_plz_1exclamation_mark11 // :D

Well, I guess some of you may have more, better suggestions. Let's see  
what the community votes for.



More information about the Digitalmars-d mailing list