Proposal: static template(fail)

Ary Borenszweig ary at esperanto.org.ar
Thu Dec 13 09:40:40 PST 2007


Janice Caron wrote:
> On 12/13/07, Jason House <jason.james.house at gmail.com> wrote:
>> Janice Caron Wrote:
>>
>>> On 12/13/07, Aziz K. <aziz.kerim at gmail.com> wrote:
>>>> Why not use a static assert: static assert(0, "Substitution Failure");
>>> A static assert is a compile error. Different thing. What you want is
>>> for the template not to be instanted, not for it to be instantiated
>>> with a compile error.
>>>
>>> Put it another way. Suppose you write
>>>
>>>     S(int) s;
>>>
>>> Which would you prefer - an error message saying that s couldn't be
>>> instantiated (giving the filename and line number of the above line),
>>> or an error message saying that a static assert in the middle of some
>>> library file had been hit?
>> I'd prefer a static assert.
>> As with all errors, I'd want a backtrace.
> 
> You're missing the point, which is IT'S NOT AN ERROR. It's a
> substitution failure - and substitution failure IS NOT AN ERROR.
> That's a basic principle of template programming.

I don't understand how it's not an error if you can't instantiate the 
template.



More information about the Digitalmars-d mailing list