Why code complexity metrics fail on the C++ standard template library ∗

Since McCabe’s cyclometric measure, structural complexity have been playing an important role measuring the complexity of programs. Complexity metrics are used to achieve more maintainable code with the least bugs possible. C++ Standard Template Library (STL) is the most popular library based on the generic programming paradigm. This paradigm allows implementation of algorithms and containers in an abstract way to ensure the configurability and collaboration of the abstract components. STL is widely used in industrial softwares because STL’s appropriate application decreases the complexity of the code significantly. Many new potential errors arise by the usage of the generic programming paradigm, including invalid iterators, notation of functors, etc. In this paper we present many complexity inconsistencies in the application of STL that a precise metric must take into account, but the existing measures ignore the characteristics of STL.