Article ID | Journal | Published Year | Pages | File Type |
---|---|---|---|---|
423294 | Electronic Notes in Theoretical Computer Science | 2011 | 13 Pages |
The C++ Standard Template Library is a widely-used library that is based on the generic programming paradigm. The usage of this library does not warrant bug-free programs. Furthermore, many new errors may arise from the inaccurate use of the generic programming paradigm, like dereferencing invalid iterators or misunderstanding remove-like algorithms. Most of the STL algorithms have preconditions which are checked neither at compilation time nor at runtime. Violation of such a precondition results in undefined behaviour. In this paper we propose solutions for a subset of these problems. The techniques we describe help programmers use generic algorithms on sorted intervals in a safer way. We present a new iterator adaptor type and tag as well as safe containers which keep track their iteratorsʼ validness. We measure the runtime overhead of these extensions.