On 14 mai, 05:12, galathaea <galath...@[EMAIL PROTECTED]
> wrote:
> On May 10, 5:14 am, Francis Glassborow
> > It was at that point (around 1994) that RTTI was added.
>
> and it failed horribly to provide what was needed
>
> what was needed was enough introspection to automate serialisation
No.
RTTI is not introspection.
RTTI, as the name says, is just a way to identify types at runtime.
Bundling it in the language allows to reuse the pointer to the vtable
of polymorphic objects as identifiers.
The only way it fails, in my opinion, is that typeid(SomeType) is not
a constant expression, preventing usage in switch/cases.
> i.e.
> - a way to automatically get an identifier for an object
> that _uniquely_ identified it's type across runtimes
It does identify it uniquely.
The fact that it may not work across different implementations is
irrelevant.
> - a means of enumerating
> and iterating
> over the member variables and up the inheritance hierarchy
That was *never* the goal of RTTI.
That kind of thing is provided at compile-time (much more useful than
at runtime) by tuples, and you can trivially add it to your own types
with Boost.MPL for example.
That kind of facility is only useful in generic programming. Maybe
> neither of these objectives were fulfilled
That's good, since these were *not* the objectives.
I'm happy RTTI wasn't even more bloated by useless runtime
introspection data.
> i'm still not positive any of this will be possible in c++0X
Iterating over the member variables of any class type won't be in C+
+0x, no.
It wouldn't be too complicated, but first you'd probably have to add
Boost.MPL or better in the standard library.
Ideally you could also have sup****t of typedefs, member variables
(overloads, templates...) etc. With good introspection you could
easily reimplement concepts, and more.
--
[ See http://www.gotw.ca/resources/clcm.htm
for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]


|