SPRUIV4D May 2020 – May 2024
Some C++ features incur in a run-time penalty. Other features are handled completely at compile-time and thus do not cause a run-time penalty. A full discussion of which C++ features do and do not incur a run-time penalty is outside the scope of this document; discussion is available from several sources on the internet and in print.
Some features that do incur a run-time penalty are so useful in providing the desired level of abstraction and/or safety, that you should consider using them anyway. Here are some guidelines for some of the more commonly-used features:
These features have potential run-time overheads. Consider whether the benefits are worth the cost:
new()
, although this is essentially no more or less
expensive than malloc()
new()
Use these features freely, as they have little to no run-time overhead:
The following features improve performance and should be used where possible:
const
constexpr