Gave explanation for 'assert' and use of templates.

This commit is contained in:
Ralph Tandetzky
2015-03-07 20:46:00 +01:00
parent 0a15944665
commit a49760dde6

View File

@@ -282,9 +282,11 @@ assert(registerSomeThing()); // make sure that registerSomeThing() returns true
``` ```
The above code succeeds when making a debug build, but gets removed by the compiler when making a release build, giving you different behavior between debug and release builds. The above code succeeds when making a debug build, but gets removed by the compiler when making a release build, giving you different behavior between debug and release builds.
This is because `assert()` is a macro which expands to nothing in release mode.
## Don't be afraid of templates ## Don't be afraid of templates
They can help you stick to DRY principles. They can help you stick to DRY principles.
They should be preferred to macros, because macros do not honor namespaces, etc.
## Use operator overloads judiciously ## Use operator overloads judiciously