In this recipe, we will make use of assertions to detect errors at the time of compilation. Essentially, we will create a structure and will make a compile-time assertion that ensures the size of the structure is of some specific bytes. The program will abort if the size of the structure is not equal to the specified value. This constraint will help in determining the capacity of storage and also in the easy maintenance of records, that is, for deletes and updates.
Catching errors early with compile-time assertions
How to do it...
Follow these steps to create a compile-time assert expression that ensures that the user-defined structure is a specified number of bytes:
- Define a structure with a few members:
struct customers...