www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Static Assert?

reply Jerry <Jerry_member pathlink.com> writes:
What's the difference between static assert and the normal assert function? 

-J
Aug 10 2005
parent reply Sean Kelly <sean f4.ca> writes:
In article <dddh7r$jof$1 digitaldaemon.com>, Jerry says...
What's the difference between static assert and the normal assert function? 

Static assert is evaluated at compile-time. It can be useful to validate template parameters and such. Sean
Aug 10 2005
parent "Jarrett Billingsley" <kb3ctd2 yahoo.com> writes:
"Sean Kelly" <sean f4.ca> wrote in message 
news:dddin6$ld9$1 digitaldaemon.com...
 In article <dddh7r$jof$1 digitaldaemon.com>, Jerry says...
What's the difference between static assert and the normal assert 
function?

Static assert is evaluated at compile-time. It can be useful to validate template parameters and such.

I also use it for checking versions, i.e. version(VersionOne) { } else version(VersionTwo) { } else { // There must be either VersionOne or VersionTwo defined // Fail if there isn't static assert(0); }
Aug 10 2005