Boost C++ Libraries

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

QVM: Quaternions, Vectors, Matrices

deduce_vec2

#include <boost/qvm/deduce_vec.hpp>

namespace boost
{
    namespace qvm
    {
        template <class A,class B,int Dim>
        struct deduce_vec2
        {
            typedef /*unspecified*/ type;
        };
    }
}

Assumptions:

Requirements:

  • is_vec<deduce_vec2<A,B>::type>::value must be true
  • deduce_vec2<A,B>::type must be copyable
  • vec_traits<deduce_vec2<A,B>::type>::dim==Dim

This template is used by Boost QVM whenever it needs to deduce a vector type of certain dimension from the types of two user-supplied function parameters. The returned type must have accessible copy constructor (the A and B types themselves could be non-copyable, and either one of them may not be a vector type.)

The main template definition returns an unspecified vector type of the requested dimension with scalar_type obtained by deduce_scalar<A,B>::type, except if A and B are the same vector type V of dimension Dim, in which case V is returned, which is only suitable for copyable types. Boost QVM also defines (partial) specializations for the non-copyable vector types it produces. Users can define other (partial) specializations for their own types.

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