A System for Runtime Type Introspection in C++

  • Maximilien de Bayser
  • Renato Cerqueira
Part of the Lecture Notes in Computer Science book series (LNCS, volume 7554)


Many object-oriented languages support some kind of runtime introspection that allows programmers to navigate through meta-data describing the available classes, their attributes and methods. In general, the meta-data can be used to instantiate new objects, manipulate their attributes and call their methods. The meta-programming enabled by this kind of reflection has proven itself useful in a variety of applications such as object-relational mappings and inversion-of-control containers and test automation

Motivated by the need of programmatic support for composition and configuration of software components at runtime, in this work we show how to implement a runtime reflection support for C++11, using the available runtime type information, template metaprogramming and source code analysis. We will show the capabilities of the reflection API and the memory footprint for different kinds of meta-data. The API relies on a few features introduced by C++11, the new ISO standard for C++. Our reflection system is not invasive as it requires no modifications whatsoever of the application code.


reflection introspection C++ 


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.


  1. 1.
    Fowler, M.: Inversion of control containers and the dependency injection pattern,
  2. 2.
    dos Reis, V.Q., Cerqueira, R.: Controlling processing usage at user level: a way to make resource sharing more flexible. Concurr. Comput.: Pract. Exper. 22(3), 278–294 (2010)Google Scholar
  3. 3.
    Roiser, S., Mato, P.: The seal c++ reflection system. In: Proceedings of CHEP 2004, Interlaken, Switzerland, September 24-October 1, CERN-2005-02, vol. 1, p. 437. International Standard; Programming Languages - C++; ISO/IEC 14882:2003(E); 2nd edn. (October 15, 2003); ISO, CH-1211 Geneva 20 (2004)Google Scholar
  4. 4.
    Devadithya, T., Chiu, K., Lu, W.: C++ reflection for high performance problem solving environments. In: Proceedings of the 2007 Spring Simulation Multiconference - SpringSim 2007, vol. 2, pp. 435–440. Society for Computer Simulation International, San Diego (2007)Google Scholar
  5. 5.
    Veldhuizen, T.: Using template metaprograms. C++ Report 7, 26–31 (1995)Google Scholar
  6. 6.
    Czarnecki, K.: Generative Programming. Phd. thesis, Technical University of Ilmenau (1998)Google Scholar
  7. 7.
    Alexandrescu, A.: Modern C++ Desing. Addison-Wesley (2001)Google Scholar
  8. 8.
    Alexandrescu, A.: Discriminated unions. C/C++ Users Journal (April 2002)Google Scholar
  9. 9.
    Becker, T.: On the tension between object-oriented and generic programming in C++ and what type erasure can do about it,
  10. 10.
    Henney, K.: Valued conversions. C++ Report (July-August 2000)Google Scholar
  11. 11.
    Boost C++ libraries,
  12. 12.
  13. 13.
    Preney, P.: Applying std::tuple to functors efficiently,
  14. 14.
    Clang C language family frontend for LLVM,
  15. 15.
    Clugston, D.: Member function pointers and the fastest possible C++ delegates,
  16. 16.
  17. 17.
    Knizhnik, K.: Reflection for C++,
  18. 18.
    MSDN: Reflection in C++, Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2012

Authors and Affiliations

  • Maximilien de Bayser
    • 1
  • Renato Cerqueira
    • 1
  1. 1.Pontifcia Universidade Catlica do Rio de JaneiroBrasil

Personalised recommendations