Determine the size of object without its virtual table pointers

Is there a generic way (not platform dependent) to get at compile time the size of a class object in the memory, without counting the vtable pointers?


As you are asking for a portable way:

class MyClass { private: struct S { DataMemberType1 dataMember1; ... DataMemberTypeN dataMemberN; } m; public: static const size_t MemberSize = sizeof(S); };


Use sizeof on this class, it doesn't include size of the vtable just the pointer.


  • What's the fastest way to partition a sas dataset for batch processing?
  • Why derived class does not have the vtable pointer and used instead vtable of the base class?
  • Can an empty virtual table exist?
  • c++ reinterpret_cast, virtual, and templates ok?
  • How can I convert this tuple of tuples into a count of its elements?
  • Python : number of characters in text file
  • Convert date string value from U.S. to native Date with current locale U.S.?
  • Declare a C++ class without defining it in the current translation unit
  • Git subtree post hook
  • Xamarin forms toggle button default color on IOS
  • eC (Ecere) how to not worry about private data fields of a class
  • Kinect API written solely in Java without native functions?
  • including Python.h in C++ file CDT
  • How to create a data template dependent on an XML Attribute?
  • PHP: Very simple Encode/Decode string
  • How do I recognize a line break with a switch case that evaluates a char in Java?
  • Using constants or global variables in 3 tier console application
  • On which thread JavaFX change listeners are executed ?
  • Consuming a web service with the Netbeans Platform
  • Checking a play current mode makes an error occur
  • Android Chronometer starts and stops but carries on counting when stopped
  • Query pkg-config variable through autotools
  • Where these are stored?
  • How to use Windows Media Foundation with UWP without a topology
  • Jquery Knockout: ko.computed() vs classic function?
  • Spark job failing in YARN mode
  • How VBA declared Volatility works
  • Creating Java object from class name with constructor, which contains parameters [duplicate]
  • x64 applications using gdi+: what are the consequences on performance?
  • How to define and use opencv mat of user type
  • How do I open a C file with a relative path?
  • Record samples being played with OpenAL
  • If I include Java 8 in my Android app does that affect which devices it will work on?
  • DotNetZip - Calculate final zip size before calling Save(stream)
  • Sony Xperia Z Tablet not found by adb
  • AT Commands to Send SMS not working in Windows 8.1
  • Rails 2: use form_for to build a form covering multiple objects of the same class
  • Benchmarking RAM performance - UWP and C#
  • How do I configure my settings file to work with unit tests?
  • Is it possible to post an object from jquery to bottle.py?