Implementation of a Finite State Machine with Active Libraries in C++

  • Zoltán Juhász
  • Ádám Sipos
  • Zoltán Porkoláb
Part of the Lecture Notes in Computer Science book series (LNCS, volume 5235)


Active libraries are code parts playing an active role during compilation. In C++ active libraries are implemented with the help of template metaprogramming (TMP) techniques. In this paper we present an active library designed as an implementation tool for Finite state machines. With the help of various TMP constructs, our active library carries out compile-time actions like optimizations via state-minimalization, and more sophisticated error-detection steps. Our library provides extended functionality to the Boost::Statechart library, the popular FSM implementation of the Boost library. We describe the implementation and analyze the efficiency.


State Machine Finite State Machine Compilation Time Code Size Sanity Check 
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.
    Abrahams, D., Gurtovoy, A.: C++ template metaprogramming, Concepts, Tools, and Techniques from Boost and Beyond. Addison-Wesley, Boston (2004)Google Scholar
  2. 2.
    Alexandrescu, A.: Modern C++ Design: Generic Programming and Design Patterns Applied. Addison-Wesley, Reading (2001)Google Scholar
  3. 3.
    ANSI/ISO C++ Committee. Programming Languages – C++. ISO/IEC 14882:1998(E). American National Standards Institute (1998)Google Scholar
  4. 4.
  5. 5.
    Boost Metaprogramming library,
  6. 6.
    Czarnecki, K., Eisenecker, U.W.: Generative Programming: Methods, Tools and Applications. Addison-Wesley, Reading (2000)Google Scholar
  7. 7.
    Czarnecki, K., Eisenecker, U.W., Glck, R., Vandevoorde, D., Veldhuizen, T.L.: Generative Programmind and Active Libraries. Springer, Heidelberg (2000)Google Scholar
  8. 8.
    James, O.: Coplien: Curiously Recurring Template Patterns. C++ Report (February 1995)Google Scholar
  9. 9.
  10. 10.
    Fajardo, V., Ohba, Y.: Open Diameter,
  11. 11.
    Gil, Y., Lenz, K.: Simple and Safe SQL Queries with C++ Templates. In: Proceedings of the 6th international conference on Generative programming and component engineering, pp. 13–24, Salzburg, Austria (2007)Google Scholar
  12. 12.
    Gregor, D., Jrvi, J., Siek, J.G., Reis, G.D., Stroustrup, B., Lumsdaine, A.: Concepts: Linguistic Support for Generic Programming in C++. In: Proceedings of the 2006 ACM SIGPLAN conference on Object-oriented programming, systems, languages, and applications (OOPSLA 2006) (October 2006)Google Scholar
  13. 13.
    Solodkyy, Y., Järvi, J., Mlaih, E.: Extending Type Systems in a Library — Type-safe XML processing in C++. In: Workshop of Library-Centric Software Design at OOPSLA 2006, Portland Oregon (2006)Google Scholar
  14. 14.
    Hopcroft, J.E., Motwani, R., Ullman, J.D.: Introduction to Automata Theory, Languages, and Computation. Addison-Wesley, Reading (2000)zbMATHGoogle Scholar
  15. 15.
    Juhász, Z.: Implementing Finite State Automata with Active Libraries M.Sc. Thesis. Budapest (2006)Google Scholar
  16. 16.
    Karlsson, B.: Beyond the C++ Standard Library, An Introduction to Boost. Addison-Wesley, Reading (2005)Google Scholar
  17. 17.
    Knuth, D.E.: An Empirical Study of FORTRAN Programs. Software - Practice and Experience 1, 105–133 (1971)CrossRefzbMATHGoogle Scholar
  18. 18.
    McNamara, B., Smaragdakis, Y.: Static interfaces in C++. In: First Workshop on C++ Template Metaprogramming (October 2000)Google Scholar
  19. 19.
    Musser, D.R., Stepanov, A.A.: Algorithm-oriented Generic Libraries. Software-practice and experience 27(7), 623–642 (1994)CrossRefGoogle Scholar
  20. 20.
    Hopcroft, J.E., Motwani, R., Ullman, J.: Introduction to Automata Theory, Languages, and Computation. Addison-Wesley, Reading (1969)zbMATHGoogle Scholar
  21. 21.
    Programming languages C++, ISO/IEC 14882 (2003)Google Scholar
  22. 22.
    Samek, M.: Practical Statecharts in C/C++. CMP Books (2002)Google Scholar
  23. 23.
    Siek, J., Lumsdaine, A.: Concept checking: Binding parametric polymorphism in C++. In: First Workshop on C++ Template Metaprogramming (October 2000)Google Scholar
  24. 24.
    Siek, J.: A Language for Generic Programming. PhD thesis, Indiana University (August 2005)Google Scholar
  25. 25.
    Stroustrup, B.: The C++ Programming Language Special Edition. Addison-Wesley, Reading (2000)zbMATHGoogle Scholar
  26. 26.
    Stroustrup, B.: The Design and Evolution of C++. Addison-Wesley, Reading (1994)Google Scholar
  27. 27.
    Unruh, E.: Prime number computation. ANSI X3J16-94-0075/ISO WG21-462Google Scholar
  28. 28.
    Vandevoorde, D., Josuttis, N.M.: C++ Templates: The Complete Guide. Addison-Wesley (2003)Google Scholar
  29. 29.
    Veldhuizen, T.L., Gannon, D.: Active libraries: Rethinking the roles of compilers and libraries. In: Proceedings of the SIAM Workshop on Object Oriented Methods for Inter-operable Scientic and Engineering Computing (OO 1998), pp. 21–23. SIAM Press, Philadelphia (1998)Google Scholar
  30. 30.
    Veldhuizen, T.: Five compilation models for C++ templates. In: First Workshop on C++ Template Metaprogramming (October 2000)Google Scholar
  31. 31.
    Veldhuizen, T.: Using C++ Template Metaprograms. C++ Report 7(4), 36–43 (1995)Google Scholar
  32. 32.
    Veldhuizen, T.: Expression Templates. C++ Report 7(5), 26–31 (1995)Google Scholar
  33. 33.
    Zólyomi, I., Porkoláb, Z.: Towards a template introspection library. In: Karsai, G., Visser, E. (eds.) GPCE 2004. LNCS, vol. 3286, pp. 266–282. Springer, Heidelberg (2004)CrossRefGoogle Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2008

Authors and Affiliations

  • Zoltán Juhász
    • 1
  • Ádám Sipos
    • 1
  • Zoltán Porkoláb
    • 1
  1. 1.Department of Programming Languages and Compilers Faculty of InformaticsEötvös Loránd UniversityBudapestHungary

Personalised recommendations