Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3991642
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T06:38:26+00:00 2026-05-20T06:38:26+00:00

I am finding it difficult to find anyway to implement Reflection in C++. I

  • 0

I am finding it difficult to find anyway to implement Reflection in C++. I have only seen examples from AGM::LibReflection and Game Programming Gems 5. Does anyone know of a tutorial or decent code sample for how to do this?

So far I know of Boost/QT’s built in system, but I am not looking to use theirs (please do not hamper on this, I find it bloated and I want to roll my own, do not derail the topic).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T06:38:26+00:00Added an answer on May 20, 2026 at 6:38 am

    Reflection is rotten way to inspect properties of a program. You can only “reflect” what the guy designing the compiler wired into the reflection machinery. That’s usually not a lot (what reflection system do you know that will let you peer inside an expression?) and it depends on the language. And for something like C++, where you are trying to add reflection on top of the language essentially as set of APIs, you are going to be extremely limited, or you’ll have to code in truly stilted style that lets you in effect declare the reflection data as standard data structures.

    You could instead use a program transformation engine (PTS). Such an engine manipulates the complete program representation, and can thus technically answer any question which is answerable. In particular, it can in principle answer all the reflection questions you can imagine, because it acts as a substitute for the compiler, and can see everything the compiler sees.
    (In fact, it can see more than the compiler sees; the compiler is limited to one compilation unit at a time, and a good PTS can see an arbitrarily big set of compilation units concurrently, and can thus answer questions about the set as a whole).

    Our DMS Software Reengineering Toolkit can parse full (and many dialects of) C++, builts ASTs and accurate symbol tables. Using that, you can implement any static computable reflection, and then use that to produce analysis results or modify the ASTs directly.

    DMS is language agnostic; it can do this for a large variety of languages.

    Regarding actually using DMS to do “reflection”: OP wanted to know how one might implement property getters and setters. With a PTS like DMS, you parse the source code of the class of interest, and then walk the AST for the code. For each data declaration inside the class, you literally manufacture a getter for that data, by building up the AST that represents the getter code; for tools like DMS, you can do this by composing patterns of C++ source code that are interpreted to represent the corresponding AST fragments, complete with placeholders you can fill in with other ASTs. Minor transformations can then modify the original AST to include the generated getters/setters; this produces an AST that contains the original code and the generated getters/setters. A final step is to regenerat code from the AST, which DMS does by using AST-to-source prettyprinters that are part of the “domain definition” (parser, prettyprinter, name resolver) that make up the language (e.g., C++) front end.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm finding it difficult to find a decent example on how to implement a
I'm finding it difficult to find examples of using jQuery, so my bad for
I have never used VSTO and I am finding it difficult to find a
I'm finding it difficult to find any discussion on best practices for dealing with
I'm finding it really difficult to find an introduction to the object model used
I have been facing difficult time finding which browsers support which HTML 5 API
Currently I am designing a website and I am finding it VERY difficult to
Finding windows FastCGI help is proving very difficult. Any help would be greatly apprciated.
I am new to prototype and finding it a lot more difficult than jquery.
I'm currently having difficulty finding a way of making my loops work. I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.