class compile_assertion

If we need to assert a constraint that can be calculated at compile time, then it would be advantageous to do so - moving error detection to an earlier phase in development is always a Good Thing. More...

Full namedbg::compile_assertion
Definition#include <dbg.h>
Template formcompile_assertion<bool expression>
List of all Methods
Annotated List
Files
Globals
Hierarchy
Index

No members


Detailed Description

If we need to assert a constraint that can be calculated at compile time, then it would be advantageous to do so - moving error detection to an earlier phase in development is always a Good Thing.

This utility allows you to do this. You use it like this:


     enum { foo = 4, bar = 6 };
     compile_assertion<(foo > bar)>();

There is a particular point to observe here. Although the expression is now a template parameter, it is important to contain it in parentheses. This is simply because the expression contains a ">" which otherwise would be taken by the compiler to be the closing of the template parameter. Although not all expressions require this, it is good practice to do it at all times.


Generated by: pg1 on imgpc030 on Tue Sep 16 13:46:16 2003, using kdoc 2.0a54.