Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

Share this Page URL
Help

STL: Algorithms > Use a checked STL implementation - Pg. 160

160 C++ Coding Standards 83. Use a checked STL implementation. Summary Safety first (see Item 6): Use a checked STL implementation, even if it's only available for one of your compiler platforms, and even if it's only used during pre-release testing. Discussion Just like pointer mistakes, iterator mistakes are far too easy to make and will usually silently compile but then crash (at best) or appear to work (at worst). Even though your compiler doesn't catch the mistakes, you don't have to rely on "correction by visual inspection," and shouldn't: Tools exist. Use them. Some STL mistakes are distressingly common even for experienced programmers: Using an invalidated or uninitialized iterator: The former in particular is easy to do. Passing an out-of-bounds index: For example, accessing element 113 of a 100- element container. Using an iterator "range" that isn't really a range: Passing two iterators where the