2

Before I begin- I know that a polymorphic object has a vtable to select the correct method at runtime. However, is there any more additional information each polymorphic object contains (excluding the vtable)?

I am trying to measure the size/cost of a polymorphic object with RTTI enabled, compared with a non-polymorphic object. I only know about the vtable overhead and wondered what else is stored within RTTI.

EDIT: Lets say for the GCC compiler

user997112
  • 29,025
  • 43
  • 182
  • 361
  • Imagine that the compiler added a hidden function to the vtable: `GetAllRTTIdata`. Since the vtable only exists once per class and not once per object, and you're only adding a single entry to it, the overhead is nearly nonexistent. – Mark Ransom Jan 04 '14 at 05:49

1 Answers1

0

There may be an implementation-defined type name there, too (for std::type_info::name(), which can contain in theory absolutely anything), but otherwise it's pretty much just the vtable. Certainly I can't think of anything else that needs to be there in order to satisfy the rules of the language.

Not much more can be said in the general case; this is completely down to the implementation, and you didn't specify one. Some compiler could include a recipe for chicken soup if it really wanted to.

Lightness Races in Orbit
  • 378,754
  • 76
  • 643
  • 1,055