Support for the Evolution of C++ Generic Functions

  • Peter Pirkelbauer
  • Damian Dechev
  • Bjarne Stroustrup
Part of the Lecture Notes in Computer Science book series (LNCS, volume 6563)

Abstract

The choice of requirements for an argument of a generic type or algorithm is a central design issue in generic programming. In the context of C++, a specification of requirements for a template argument or a set of template arguments is called a concept.

In this paper, we present a novel tool, TACE (template analysis and concept extraction), designed to help programmers understand the requirements that their code de facto imposes on arguments and help simplify and generalize those through comparisons with libraries of well-defined and precisely-specified concepts. TACE automatically extracts requirements from the body of function templates. These requirements are expressed using the notation and semantics developed by the ISO C++ standards committee. TACE converts implied requirements into concept definitions and compares them against concepts from a repository. Components of a well-defined library exhibit commonalities that allow us to detect problems by comparing requirements from many components: Design and implementation problems manifest themselves as minor variations in requirements. TACE points to source code that cannot be constrained by concepts and to code where small modifications would allow the use of less constraining concepts. For people who use a version of C++ with concept support, TACE can serve as a core engine for automated source code rejuvenation.

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. 1.
    Abrahams, D., Gurtovoy, A.: C++ Template Metaprogramming: Concepts, Tools, and Techniques from Boost and Beyond (C++ in Depth Series). Addison-Wesley Professional, Reading (2004)Google Scholar
  2. 2.
    Agesen, O., Palsberg, J., Schwartzbach, M.: Type inference of SELF. In: Wang, J. (ed.) ECOOP 1993. LNCS, vol. 707, pp. 247–267. Springer, Heidelberg (1993)Google Scholar
  3. 3.
    Alexandrescu, A.: Modern C++ design: generic programming and design patterns applied. Addison-Wesley Longman Publishing Co., Inc., Boston (2001)Google Scholar
  4. 4.
    An, P., Jula, A., Rus, S., Saunders, S., Smith, T., Tanase, G., Thomas, N., Amato, N., Rauchwerger, L.: STAPL: A standard template adaptive parallel C++ library. In: Dietz, H.G. (ed.) LCPC 2001. LNCS, vol. 2624, pp. 193–208. Springer, Heidelberg (2003)CrossRefGoogle Scholar
  5. 5.
    Austern, M.H.: Generic programming and the STL: using and extending the C++ Standard Template Library. Addison-Wesley Longman Publishing Co., Inc., Boston (1998)Google Scholar
  6. 6.
    Becker, P.: The C++ Standard Library Extensions: A Tutorial and Reference, 1st edn. Addison-Wesley Professional, Boston (2006)Google Scholar
  7. 7.
    Becker, P.: Working draft, standard for programming language C++. Tech. Rep. N2914 (June 2009)Google Scholar
  8. 8.
    Damas, L., Milner, R.: Principal type-schemes for functional programs. In: POPL 1982: Proceedings of the 9th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, pp. 207–212. ACM, New York (1982)CrossRefGoogle Scholar
  9. 9.
    Dos Reis, G., Stroustrup, B.: A C++ formalism. Tech. Rep. N1885, JTC1/SC22/WG21 C++ Standards Committee (2005)Google Scholar
  10. 10.
    Dos Reis, G., Stroustrup, B.: Specifying C++ concepts. In: POPL 2006: Conference Record of the 33rd ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, pp. 295–308. ACM Press, New York (2006)CrossRefGoogle Scholar
  11. 11.
    Dos Reis, G., Stroustrup, B.: A principled, complete, and efficient representation of C++. In: Suzuki, M., Hong, H., Anai, H., Yap, C., Sato, Y., Yoshida, H. (eds.) The Joint Conference of ASCM 2009 and MACIS 2009, COE, Fukuoka, Japan. MI Lecture Note Series, vol. 22, pp. 151–166 (December 2009)Google Scholar
  12. 12.
    Dos Reis, G., Stroustrup, B., Meredith, A.: Axioms: Semantics aspects of C++ concepts. Tech. Rep. N2887, JTC1/SC22/WG21 C++ Standards Committee (June 2009)Google Scholar
  13. 13.
    Gregor, D., Järvi, J., Siek, J., Stroustrup, B., Dos Reis, G., Lumsdaine, A.: Concepts: linguistic support for generic programming in C++. In: OOPSLA 2006: Proceedings of the 21st Annual ACM SIGPLAN Conference on Object-Oriented Programming Systems, Languages, and Applications, pp. 291–310. ACM Press, New York (2006)CrossRefGoogle Scholar
  14. 14.
    Gregor, D., Stroustrup, B., Siek, J., Widman, J.: Proposed wording for concepts (revision 4). Tech. Rep. N2501, JTC1/SC22/WG21 C++ Standards Committee (February 2008)Google Scholar
  15. 15.
    ISO/IEC 14882 International Standard: Programming languages: C++. American National Standards Institute (September 1998)Google Scholar
  16. 16.
    Järvi, J., Gregor, D., Willcock, J., Lumsdaine, A., Siek, J.: Algorithm specialization in generic programming: challenges of constrained generics in C++. In: PLDI 2006: Proceedings of the 2006 ACM SIGPLAN Conference on Programming Language Design and Implementation, pp. 272–282. ACM, New York (2006)CrossRefGoogle Scholar
  17. 17.
    Järvi, J., Marcus, M.A., Smith, J.N.: Library composition and adaptation using C++ concepts. In: GPCE 2007: Proceedings of the 6th International Conference on Generative Programming and Component Engineering, pp. 73–82. ACM Press, New York (2007)CrossRefGoogle Scholar
  18. 18.
    Järvi, J., Willcock, J., Hinnant, H., Lumsdaine, A.: Function overloading based on arbitrary properties of types. C/C++ Users Journal 21(6), 25–32 (2003)Google Scholar
  19. 19.
    Peterson, J., Jones, M.: Implementing type classes. In: PLDI 1993: Proceedings of the ACM SIGPLAN 1993 Conference on Programming Language Design and Implementation, pp. 227–236. ACM Press, New York (1993)CrossRefGoogle Scholar
  20. 20.
    Siek, J., Lumsdaine, A.: Concept checking: Binding parametric polymorphism in C++. In: First Workshop on C++ Template Programming, Erfurt, Germany, October 10 (2000)Google Scholar
  21. 21.
    Siek, J.G., Lee, L.Q., Lumsdaine, A.: The Boost Graph Library: user guide and reference manual. Addison-Wesley Longman Publishing Co., Inc., Boston (2002)Google Scholar
  22. 22.
    Stepanov, A., McJones, P.: Elements of Programming. Addison-Wesley Professional, Reading (2009)Google Scholar
  23. 23.
    Stroustrup, B.: The design and evolution of C++. ACM Press/Addison-Wesley Publishing Co, New York, NY, USA (1994)Google Scholar
  24. 24.
    Stroustrup, B.: The C++ Programming Language. Addison-Wesley Longman Publishing Co., Inc., Boston (2000)Google Scholar
  25. 25.
    Stroustrup, B.: Abstraction and the C++ machine model. In: Wu, Z., Chen, C., Guo, M., Bu, J. (eds.) ICESS 2004. LNCS, vol. 3605, pp. 1–13. Springer, Heidelberg (2005)CrossRefGoogle Scholar
  26. 26.
    Stroustrup, B.: The C++0x “remove concept” decision. Dr. Dobb’s Journal 92 (August 2009) (republished with permission in Overload Journal July 2009)Google Scholar
  27. 27.
    Stroustrup, B.: Expounds on concepts and the future of C++. Interview with Danny Kalev (August 2009)Google Scholar
  28. 28.
    Sutton, A., Maletic, J.I.: Automatically identifying C++0x concepts in function templates. In: ICSM 2008: 24th IEEE International Conference on Software Maintenance, Beijing, China, pp. 57–66. IEEE, Los Alamitos (2008)CrossRefGoogle Scholar
  29. 29.
    Wadler, P., Blott, S.: How to make ad-hoc polymorphism less ad hoc. In: POPL 1989: Proceedings of the 16th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, pp. 60–76. ACM, New York (1989)CrossRefGoogle Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2011

Authors and Affiliations

  • Peter Pirkelbauer
    • 1
  • Damian Dechev
    • 2
  • Bjarne Stroustrup
    • 3
  1. 1.Lawrence Livermore National LaboratoryCenter for Applied Scientific ComputingLivermoreUS
  2. 2.Department of Electrical Engineering and Computer ScienceUniversity of Central FloridaOrlandoUS
  3. 3.Department of Computer Science and EngineeringTexas A&M UniversityCollege StationUS

Personalised recommendations