Extension of iterator traits in the C++ Standard Template Library

The C++ Standard Template Library is the flagship example for libraries based on the generic programming paradigm. The usage of this library is intended to minimize classical C/C++ error, but does not warrant bug-free programs. Furthermore, many new kinds of errors may arise from the inaccurate use of the generic programming paradigm, like dereferencing invalid iterators or misunderstanding remove-like algorithms. In this paper we present typical scenarios, that can cause runtime problems. We emit warnings while these constructs are used without any modification in the compiler. We argue for an extension of the STL's iterator traits in order to emit these warnings. We also present a general approach to emit “customized” warnings. We support the so-called believe-me marks to disable warnings.

[1]  Norbert Pataki ADVANCED FUNCTOR FRAMEWORK FOR C++ STANDARD TEMPLATE LIBRARY , 2011 .

[2]  Bjarne Stroustrup,et al.  Concepts: linguistic support for generic programming in C++ , 2006, OOPSLA '06.

[3]  Scott Meyers,et al.  Effective STL: 50 Specific Ways to Improve Your Use of the Standard Template Library , 2001 .

[4]  Tamás Kozsik Tutorial on Subtype Marks , 2005, CEFP.

[5]  Bjarne Stroustrup,et al.  The C++ Programming Language: Special Edition , 2000 .

[6]  Matthew H. Austern Generic programming and the STL - using and extending the C++ standard template library , 1999, Addison-Wesley professional computing series.

[7]  Sibylle Schupp,et al.  STLlint: lifting static checking from languages to libraries , 2006, Softw. Pract. Exp..

[8]  Zoltán Porkoláb,et al.  Towards a General Template Introspection Library , 2004, GPCE.

[9]  Mads Torgersen The expression problem revisited: Four new solutions using generics , 2004 .

[10]  Jaakko Järvi,et al.  Algorithm specialization in generic programming: challenges of constrained generics in C++ , 2006, PLDI '06.

[11]  Andrei Alexandrescu,et al.  Modern C++ Design , 2001 .

[12]  Norbert Pataki,et al.  Measuring the Overhead of C++ Standard Template Library Safe Variants , 2011, Electron. Notes Theor. Comput. Sci..

[13]  Douglas Gregor,et al.  STLlint: lifting static checking from languages to libraries , 2006 .

[14]  Yann-Gaël Guéhéneuc,et al.  Inconsistencies of Metrics in C + + Standard Template Library ? , 2007 .

[15]  Leor Zolman An STL message decryptor for visual C , 2001 .

[16]  Thomas Becker STL & generic programming: writing your own iterators , 2001 .