How to enforce compile time evaluation (and test if it was done at compile time)

sarn via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Feb 28 01:16:47 PST 2017


On Tuesday, 28 February 2017 at 07:41:36 UTC, Christian Köstlin 
wrote:
> As I understand the only difference between assert and enforce 
> is, that
> assert is not compiled into releases?
>
> Thanks!
> Christian

Pretty much so.  The intention is that assert means something 
that's supposed to be true (and can be assumed in release) while 
enforce means something you want to be true (but can't guarantee).

E.g., you can assert that a list is sorted after running heapsort 
on it, but you need to enforce that a file is in the correct 
format.


More information about the Digitalmars-d-learn mailing list