Note that there are some explanatory texts on larger screens.

plurals
  1. POInteger class wrapper performance
    text
    copied!<p>I am looking to remodel an existing library for fixed point numbers. Currently the library is just namespaced functions operating on 32-bit signed integers. I would like to turn this around and create a fixed point class that wraps an integer, but don't want to pay any performance penalty associated with classes for something this fine-grained, as performance is an issue for the use case.</p> <p>Since the prospective class has such simple data requirements, and no resources, I thought it might be possible to make the class "value oriented", leveraging non-modifying operations and passing instances by value where reasonable. This will be a simple class if implemented, not part of a hierarchy.</p> <p>I am wondering if it is possible to write an integer wrapper class in such a way that no real performance penalty is incurred compared to using raw integers. I am almost confident that this is the case, but don't know enough about the compilation process to just jump into it.</p> <p>I know that it's said that stl iterators are compiled to simple pointer operations, and would like to do something similar only with integer operations.</p> <p>The library will be updated to c++11 as a part of a project anyway, so I'm hoping that at least with constexpr and other new features like rvalue references, I can push the performance of this class to near that of pure integer operations.</p> <p>Additionally, any recommendations for benchmarking performance differences between the two implementations would be appreciated.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload