...one of the most highly
regarded and expertly designed C++ library projects in the
world.

— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards

#include <boost/qvm/deduce_scalar.hpp>

namespace boost { namespace qvm { template <class A,class B> struct deduce_scalar { typedef typename impl<A,B>::type type; }; } }

*A* and *B* satisfy the scalar requirements.

If *A* and *B* are the same type, *impl<A,B>::type* returns that type. Otherwise, *impl<A,B>::type* is well defined for the following types only: *signed/unsigned char*, *signed/unsigned short*, *signed/unsigned int*, *signed/unsigned long*, *float* and *double*. The deduction logic is as follows:

- if either of
*A*and*B*is*double*, the result is*double*; - else, if one of
*A*and*B*is an integer type and the other is*float*, the result is*float*; - else, if
*A*or*B*is a signed integer and the other type is unsigned integer, the signed type is changed to unsigned, and then the lesser of the two integers is promoted to the other.