Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Empty base class optimization for MSVC #305

Open
andipeer opened this issue Jan 12, 2023 · 0 comments
Open

Empty base class optimization for MSVC #305

andipeer opened this issue Jan 12, 2023 · 0 comments

Comments

@andipeer
Copy link

Please include the following information in your issue:

  1. Which version of units you are using
    3.0.0 Beta 2

  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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant