proposal: should assert behave like static assert if its possible?
Walter Bright
newshound1 at digitalmars.com
Sat Jan 19 18:33:39 PST 2008
torhu wrote:
> dennis luehring wrote:
>> my question for walter is:
>>
>> can't assert behave like static assert if the value/condition is
>> available compiletime
>>
>> for example:
>>
>> int x = byte_bit_to_int( 7, 9 ); // an static assert could do the check
>>
>> int x = byte_bit_to_int( 7, random(8) ); // the normal assert is needed
>
> The problem is that sometimes you write things like assert(0), and need
> it to trigger at runtime, not compile time. So I think there would
> still be a way to do that.
You're right (it's runtime flow of control sensitive), and that's why it
doesn't trigger at compile time.
More information about the Digitalmars-d
mailing list