proposal: should assert behave like static assert if its possible?
dennis luehring
dl.soluz at gmx.net
Sat Jan 19 01:47:58 PST 2008
hi group,
this is one of my function needed to talk to an siemens plc(sps)
int byte_bit_to_int( int byte_, int bit_ )
{
// if bit_ is compiletime value
static assert( bit_ <= 7 );
// if bit_ is runtime value
assert( bit_ <= 7 );
return byte_*8+bit_;
}
and my question is how can i make the assert as save as possible
at compile- and runtime
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
ciao dennis
More information about the Digitalmars-d
mailing list