VC 2008 and 2005 user, be careful with the slow containers with "Checked Iterators" enabled in STL
Microsoft introduced a very good feature, Checked Iterators that helps to detect a few mistakes, especially out of bounds error, on unsafe iterators use, since VC 2005 (or even earlier?).
This is a very useful feature for Debug, yes, only for debug, to capture any potential bugs such as bad iterators and pointers. But unluckily this feature is enabled in release mode by default. Consequently the STL becomes quite quite slow than normal.
For example, recently I did a benchmark to compare several callback/signal/slot implementations, and found boost::signal2 is 10 times slower than normal. Compiling with VC 2008 Express, it costs more than 20 seconds to run, but compiling with GCC 4.5.2, it only costs only about 2 seconds.
The reason is that "Checked Iterators" is enabled in release mode.
Let's disable "Checked Iterators" in release mode.
It's easy. Just define _SECURE_SCL to be 0. To define it globally, put it to the command line or put into project settings.
In my benchmark, after defined _SECURE_SCL to 0, the benchmark only needs about 2 seconds to run, comes back to the normal level.
If you are a VC 2010 user, you are already lucky because _SECURE_SCL is 0 by default in release mode.
If you are a VC 2008 or 2005 user, be sure to define _SECURE_SCL to 0 in release mode, unless you never use VC STL.