   C++ Introspection
  Alright I have to admit that I have been just learning some of the finer points to C++ -- casting up and down, namespaces, etc.  What I''m thinking of here is how to do some kind of introspection -- I''m not really seeing how this is done, or can be done.  Although just in passing, I think I saw something in the STL about introspection.  Am I wrong?  Does anyone know how this is done?Thanks,L- 
  C++''s base language types are not introspective.  For instance, you cannot write a routine that will serialize any class, because each class doesn''t know anything about itself other than what you tell it.(Okay, you could fwrite entire classes to files but this is stupid and dumb.) ;  What is introspection? ;  yeah, i realize the base language is totally non-introspective (capable of telling you what it is.) However I think QT and some of the STL have introspection methods -- I''m just trying to get an idea of how they accomplished it.thanks,L- ;  QT gets the benefit of being run through the metaobject compiler (MOC) before being passed onto the actual compiler, at which point I think type information can be generated and inserted into the final file. I''m not sure on how it works, I know MOC is required for signals/slots.As for STL, how can it be introspective? Everything it does is through templates. ;quote:Original post by brain21  What is introspection?   Broadly speaking, the ability to query a construct for its supported features, at run time.e.g. - Getting an object to provide you with a list of its member functions, and being able to use that list to actually call them.   “Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.”    — Brian W. Kernighan (C programming language co-inventor);  You have to generate the classes using an automatic means (meta-template), or use macro wrappers around your declarations which also add stuff to the class for introspection.As an exercise, I wrote a meta-template that would print out the class declaration from such a class description.As useful as this capabilities seems, I haven''t found it all that useful in practice.  Too often you can''t serialize the class automatically, something special needs to happen, and I never wanted to expose every method of a class to the run-time shell.-- It was more work segregating conceptual objects into multiple classes to utilize introspection automation, than it was to just code it up for each class. 