C++

Debugging in Release Mode

In VS, right click your project, chose "Properties".
- Click the C/C++ node. Set Debug Information Format to C7 compatible (/Z7) or Program Database (/Zi).
- Expand Linker and click the General node. Set Enable Incremental Linking to No (/INCREMENTAL:NO).
- Select the Debugging node. Set Generate Debug Info to Yes (/DEBUG).
- Select the Optimization node. Set References to /OPT:REF and Enable COMDAT Folding to /OPT:ICF.
That's ripped directly from http://msdn.microsoft.com/en-us/library/fsk896zz.aspx
I do this all of the time and pretty much never debug
in debug mode anymore. As you know, many errors that occur
in a release build may not occur in a debug build (almost
certainly the errors that arise from invoking UB).
Also, I work on a project which uses a ton of image
processing and performs a lot of compression/decompression
of large images. Using a slow debug build is simply impractical.

Check whether an entry exists in std::map

// in map, count will return either 0 or 1if(theMap.count(theKey)){// it exists}else{// it doesn't exist}

Attention! If an entry in a std::map does not exist and you access it, it will silently generate an entry for that key! (normally setting the value for the key to 0 if it is a numeric value, or ”” if it is a string)

Initialize a float to the smallest negative value

You can either use -FLT_MAX (or -DBL_MAX) for
the maximum magnitude negative number
and FLT_MAX (or DBL_MAX) for positive.
This gives you the range of possible float (or double) values.
You probably don't want to use FLT_MIN; it corresponds
to the smallest magnitude positive number that can be
represented with a float, not the most negative value
representable with a float.
FLT_MIN and FLT_MAX correspond to
std::numeric_limits<float>::min() and
std::numeric_limits<float>::max().