Algorithm Optimizations – Advanced STL, Part 2

Part 2 of my video lecture series exploring the Standard Template Library’s implementation is now available.  In this part, I walk through how our STL algorithms equal() and copy() use template metaprogramming to detect when it’s safe to call memcmp() and memmove(), which are potentially faster than the generic loops.

 

In Part 1’s comments, two customers reported compiler bugs to us.  While I can’t promise that they’ll be fixed in VC11, I’m happy to report that fixes for them have been queued in our checkin system, which is certainly a prerequisite for shipping them.  :->

 

This advanced series assumes that you’re familiar with C++ and the STL’s interface, but not the STL’s implementation.  If you haven’t used the STL extensively yet, I recommend watching my introductory series.  For reference, here are all of the links:

 

[STL Introduction]

Part 1 (sequence containers)

Part 2 (associative containers)

Part 3 (smart pointers)

Part 4 (Nurikabe solver) – see Wikipedia’s article and my updated source code

Part 5 (Nurikabe solver, continued)

Part 6 (algorithms and functors)

Part 7 (algorithms and functors, continued)

Part 8 (regular expressions)

Part 9 (rvalue references)

Part 10 (type traits)

 

[Advanced STL]

Part 1 (shared_ptr – type erasure)

Part 2 (equal()/copy() – algorithm optimizations)

 

Stephan T. Lavavej

Visual C++ Libraries Developer