?
=?iso-8859-1?B?RnJhbmstUmVu6SBTY2jkZmVy?=
Case:
-- class X has occupies tiny amount of memory:
sizeof(X) is only a little greater than sizeof(void*).
-- X instantiates thousands of objects and memory does matter.
-- The class has a virtual destructor, and therefore, a pointer
to a virtual function table.
-- This class, now, needs a boolean variable 'boolF' which would
cost at the very least 1 byte, which is a lot under the
circumstances described above.
--> idea: (1) copy the virtual function table at another place.
(2) let the virtual function pointer point to either
one of the virtual function tables (which are
identical), but:
The place where the pointer points to indicates the
state of the 'implicitly represented' variable
'boolF'.
Such a setup is profitable, if
N * sizeof(bool) > sizeof(virtual function table),
where N = estimated number of instantiated objects.
Does the standard impose the management of virtual function tables
strictly enough to elaborate on such a solution? Is such a
solution practical?
Thanks
Frank
-- class X has occupies tiny amount of memory:
sizeof(X) is only a little greater than sizeof(void*).
-- X instantiates thousands of objects and memory does matter.
-- The class has a virtual destructor, and therefore, a pointer
to a virtual function table.
-- This class, now, needs a boolean variable 'boolF' which would
cost at the very least 1 byte, which is a lot under the
circumstances described above.
--> idea: (1) copy the virtual function table at another place.
(2) let the virtual function pointer point to either
one of the virtual function tables (which are
identical), but:
The place where the pointer points to indicates the
state of the 'implicitly represented' variable
'boolF'.
Such a setup is profitable, if
N * sizeof(bool) > sizeof(virtual function table),
where N = estimated number of instantiated objects.
Does the standard impose the management of virtual function tables
strictly enough to elaborate on such a solution? Is such a
solution practical?
Thanks
Frank