A Feature Composition Problem and a Solution Based on C++ Template Metaprogramming

  • Zoltán Porkoláb
  • István Zólyomi
Part of the Lecture Notes in Computer Science book series (LNCS, volume 4143)


Separation of concerns and collaboration based design is usually a suitable concept for library implementation: it results in easily scalable and maintainable code. After specifying and implementing orthogonal features, we aim to easily assemble library components. In real life, components can be used only after appropriate refinement steps, progressively adding features in each step. Therefore the specific solution for a particular task can be produced by composing a set of refined components. Unfortunately, a subtype anomaly occurs in object-oriented languages between such composite components that have different numbers of features from different refinement stages. In this article we analyse this anomaly that we named chevron-shape inheritance and present a framework based on standard C++ template metaprogramming.


Feature Composition Dynamic Binding Assignment Operator Multiple Inheritance Client Code 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.


  1. 1.
    Zólyomi, I., Porkoláb, Z., Kozsik, T.: An extension to the subtype relationship in C++. In: Pfenning, F., Smaragdakis, Y. (eds.) GPCE 2003. LNCS, vol. 2830, pp. 209–227. Springer, Heidelberg (2003)CrossRefGoogle Scholar
  2. 2.
    Alexandrescu, A.: Modern C++ Design: Generic Programming and Design Patterns Applied. Addison-Wesley, Reading (2001)Google Scholar
  3. 3.
    Vandevoorde, D., Josuttis, N.M.: C++ Templates: The Complete Guide. Addison-Wesley, Reading (2003)MATHGoogle Scholar
  4. 4.
    Baumgartner, G., Russo, V.F.: Implementing Signatures for C++. ACM Transactions on Programming Languages and Systems (TOPLAS) 19(1), 153–187 (1997)CrossRefGoogle Scholar
  5. 5.
    Veldhuizen, T.: Using C++ Template Metaprograms. C++ Report 7(4), 36–43 (1995)Google Scholar
  6. 6.
    Veldhuizen, T.: Expression Templates. C++ Report 7(5), 26–31 (1995)Google Scholar
  7. 7.
    Garcia, R., Järvi, J., Lumsdaine, A., Siek, J., Willcock, J.: A Comparative Study of Language Support for Generic Programming. In: Proceedings of the 18th ACM SIGPLAN OOPSLA 2003, pp. 115–134 (2003)Google Scholar
  8. 8.
    Leroy, X., et al.: The Objective Caml system, release 3.0.8, documentation and user’s manual (July 2004),
  9. 9.
    Jeremy Siek, J.: A Language for Generic Programming. PhD thesis, Indiana University (August 2005)Google Scholar
  10. 10.
    Don Batory, A.: Tutorial on Feature Oriented Programming and the AHEAD Tool Suite. Technical Report, TR-CCTC/DI-35, GTTSE, pp. 153–186 (2005)Google Scholar
  11. 11.
    Batory, D., Sarvela, J.N., Rauschmayer, A.: Scaling Step-Wise Refinement. IEEE Transactions on Software Engineering 30(6), 355–371Google Scholar
  12. 12.
    Batory, D., Liu, J., Sarvela, J.N.: Refinements and multi-dimensional separation of concerns. In: Proceedings of the 9th European Software Engineering Conference (2003)Google Scholar
  13. 13.
    Smaragdakis, Y., Batory, D.: Mixin-Based Programming in C++. In: Proceedings of Net.Object Days 2000, pp. 464–478 (2000)Google Scholar
  14. 14.
    Smaragdakis, Y., Batory, D.: Mixin Layers: An Object-Oriented Implementation Technique for Refinements and Collaboration-Based Designs. ACM Transactions of Software Engineering and Methodology 11(2), 215–255 (2002)CrossRefGoogle Scholar
  15. 15.
    Czarnecki, K., Eisenecker, U.W.: Generative Programming: Methods, Tools and Applications. Addison-Wesley, Reading (2000)Google Scholar
  16. 16.
    Stroustrup, B.: The C++ Programming Language Special Edition. Addison-Wesley, Reading (2000)Google Scholar
  17. 17.
    Stroustrup, B.: The Design and Evolution of C++. Addison-Wesley, Reading (1994)Google Scholar
  18. 18.
    Bertrand Meyer: Eiffel: The Language. Prentice Hall, Englewood Cliffs (1991)Google Scholar
  19. 19.
    Bergmans, L., Aksit, M.: Composing Crosscutting Concerns Using Composition Filters. Communications of the ACM 44(10), 51–57 (2001)CrossRefGoogle Scholar
  20. 20.
    Cardelli, L.: Structural Subtyping and the Notion of Power Type. In: Conference Record of the Fifteenth Annual ACM Symposium on Principles of Programming Languages, San Diego, California, January 1988, pp. 70–79 (1988)Google Scholar
  21. 21.
    Kiczales, G., Lamping, J., Mendhekar, A., Maeda, C., Lopes, C.V., Loingtier, J.-M., Irwin, J.: Aspect-Oriented Programming. In: Aksit, M., Matsuoka, S. (eds.) ECOOP 1997. LNCS, vol. 1241, pp. 220–242. Springer, Heidelberg (1997)CrossRefGoogle Scholar
  22. 22.
    Kiczales, G., et al.: An overview of AspectJ. In: Knudsen, J.L. (ed.) ECOOP 2001. LNCS, vol. 2072, pp. 327–355. Springer, Heidelberg (2001)CrossRefGoogle Scholar
  23. 23.
    Baumgartner, G., Jansche, M., Läufer, K.: Half & Half: Multiply Dispatch and Retroactive Abstraction for Java. Technical Report OSU-CISRC-5/01-TR08. Ohio State University (2002)Google Scholar
  24. 24.
    Eisenecker, U.W., Blinn, F., Czarnecki, K.: A Solution to the Constructor-Problem of Mixin-Based Programming in C++. In: The GCSE, Workshop on C++ Template Programming (2000)Google Scholar
  25. 25.
    Ossher, H., Tarr, P.: Multi-Dimensional Separation of Concerns and The Hyperspace Approach. IBM Research Report 21452, IBM T.J. Watson Research Center (April 1999),
  26. 26.
    Ossher, H., Tarr, P.: Hiper/J. Multidemensional Separation of Concerns for Java. In: International Conference on Software Engineering 2001, pp. 734–737. ACM, New York (2001)Google Scholar
  27. 27.
    Harrison, W., Ossher, H.: Subject-oriented programming: a critique of pure objects. In: Proceedings of 8th OOPSLA 1993, Washington D.C., USA, pp. 411–428 (1993)Google Scholar
  28. 28.
    Subject Oriented Programming,
  29. 29.
    Shopiro, J.E.: An Example of Multiple Inheritance in C++: a Model of the Iostream Library. ACM SIGPLAN Notices (December 1989)Google Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2006

Authors and Affiliations

  • Zoltán Porkoláb
    • 1
  • István Zólyomi
    • 1
  1. 1.Department of Programming Languages and CompilersEötvös Loránd UniversityBudapestHungary

Personalised recommendations