Des, prog & doc.

Design
patterns and anti-patterns
Programming
Writing snippets for visual assist
C preprocessor and fun Macros
Google on c++
Coding advises
Documenting
File Header style
Self Documenting Code

Define Guard (google style) in Visual Assist


#ifndef $FILE_BASE_UPPER$_$FILE_EXT_UPPER$_
#define $FILE_BASE_UPPER$_$FILE_EXT_UPPER$_

$clipboard$

#endif  // $FILE_BASE_UPPER$_$FILE_EXT_UPPER$_

Clamp variable to interval


#include <iostream>
using namespace std;

float Clamp( float a )
{
 float v = (a<0) ? 0 : (a<1) ? a : 1;
 return v;
}

int main ()
{
 cout<< -3 << "\t" << Clamp(-3) <<endl;
 cout<< 0.5f << "\t" << Clamp(0.5f) <<endl;
 cout<< 3 << "\t" << Clamp(3) <<endl;
}

Output

 -3      0
0.5     0.5
3       1

You can modify function to take interval , or use it as preprocessor directive.