QVM: Quaternions, Vectors, Matrices

deduce_quat

#include <boost/qvm/deduce_quat.hpp>

namespace boost
{
    namespace qvm
    {
        template <class Q>
        struct deduce_quat
        {
            typedef Q type;
        };
    }
}

Assumption:

is_quat<Q>::value is true.

Requirements:

  • is_quat<deduce_quat<Q>::type>::value must be true
  • deduce_quat<Q>::type must be copyable

This template is used by Boost QVM whenever it needs to deduce a copyable quaternion type from a single user-supplied function parameter of quaternion type. Note that Q itself may be non-copyable.

The main template definition returns Q, which means that it is suitable only for copyable quaternion types. Boost QVM also defines (partial) specializations for the non-copyable quaternion types it produces. Users can define other (partial) specializations for their own types.

A typical use of the deduce_quat template is for specifying the preferred quaternion type to be returned by the generic function template overloads in Boost QVM depending on the type of their arguments.