Empty base class optimization for MSVC
andipeer opened this issue · comments
Please include the following information in your issue:
-
Which version of
units
you are using
3.0.0 Beta 2 -
Which compiler exhibited the problem (including compiler version)
MSVC
Problem description
In contrast to most other compilers, MSVC does not enable empty base class optimization by default. This means that when using units
on MSVC, although most method calls will be optimized away, there will be a memory overhead of at least 1 byte compared to just using plain floating point types.
Solution
As a solution, in our code base we added the empty_bases attribute to the units::unit
class in case it is compiled on MSVC. This indeed removes the memory overhead.
If you approve that this should be addressed, I can create a pull request with the required changes.