Boost C++ Libraries of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for a snapshot of the develop branch, built from commit 0f79ae966a.

The Overhead in the Number Class Wrapper

Using a simple backend class that wraps any fundamental (built-in) arithmetic type we can measure the overhead involved in wrapping a type inside the number frontend, and the effect that turning on expression templates has. The following table compares the performance between double and a double wrapped inside class number:

Table 1.12. Bessel Functions (16 digit precision)




2.09301 (0.00133409s)

arithmetic_backend<double> - no expression templates

1 (0.000637403s)


1.07956 (0.000688113s)

As you can see whether or not there is an overhead, and how large it is depends on the actual situation, but the overhead is in any cases small. Expression templates generally add a greater overhead the more complex the expression becomes due to the logic of figuring out how to best unpack and evaluate the expression, but of course this is also the situation where you save more temporaries. For a "trivial" backend like this, saving temporaries has no benefit, but for larger types it becomes a bigger win.

The following table compares arithmetic using either long long or number<arithmetic_backend<long long> > for the voronoi-diagram builder test:


Relative time



number<arithmetic_backend<int64_t>, et_off>

1.005 (0.0129255s)

This test involves mainly creating a lot of temporaries and performing a small amount of arithmetic on them, with very little difference in performance between the native and "wrapped" types.

Table 1.13. Platform Details


Linux 5.3.0-24-generic, version #26-Ubuntu SMP Thu Nov 14 01:33:18 UTC 2019, x86_64


GNU C++ version 9.2.1 20191008



Run date

Dec 13 2019