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

This is the documentation for an old version of Boost. Click here to view this page for the latest version.

QVM: Quaternions, Vectors, Matrices

Type Traits

#include <boost/qvm/quat_traits.hpp> 
#include <boost/qvm/mat_traits.hpp> 
#include <boost/qvm/vec_traits.hpp> 

namespace
boost
    {
    namespace
    qvm
        {
        //*** Type traits ***
        
        template <class T>
        struct is_quat
        {
            static bool const value=/*unspecified*/;
        };        
        
        template <class Q>
        struct quat_traits
        {
            /*main template members unspecified*/
        };
        
        /*
        User-defined (possibly partial) specializations:
        
        template <>
        struct quat_traits<Q>
        {
            typedef /*user-defined*/ scalar_type;        
        
            template <int I> static inline scalar_type read_element( Quaternion const & q );        
            template <int I> static inline scalar_type & write_element( Quaternion & q );        
        };
        */        
        
        template <class QuatType,class ScalarType>
        struct quat_traits_defaults
        {
            typedef QuatType quat_type;
            typedef ScalarType scalar_type;
        
            template <int I>
            static BOOST_QVM_INLINE_CRITICAL
            scalar_type read_element( quat_type const & x )
            {
                return quat_traits<quat_type>::template write_element<I>(const_cast<quat_type &>(x));
            }
        };        
        
        template <class T>
        struct is_vec
        {
            static bool const value=/*unspecified*/;
        };        
        
        template <class V>
        struct vec_traits
        {
            /*main template members unspecified*/
        };
        
        /*
        User-defined (possibly partial) specializations:
        
        template <>
        struct vec_traits<V>
        {
            static int const dim = /*user-defined*/;        
            typedef /*user-defined*/ scalar_type;        
        
            template <int I> static inline scalar_type read_element( Vector const & v );        
            template <int I> static inline scalar_type & write_element( Vector & v );        
        
            static inline scalar_type read_element_idx( int i, Vector const & v );        
            static inline scalar_type & write_element_idx( int i, Vector & v );        
        };
        */        
        
        template <class VecType,class ScalarType,int Dim>
        struct vec_traits_defaults
        {
            typedef VecType vec_type;
            typedef ScalarType scalar_type;
            static int const dim=Dim;
        
            template <int I>
            static BOOST_QVM_INLINE_CRITICAL
            scalar_type write_element( vec_type const & x )
            {
                return vec_traits<vec_type>::template write_element<I>(const_cast<vec_type &>(x));
            }
        
            static BOOST_QVM_INLINE_CRITICAL
            scalar_type read_element_idx( int i, vec_type const & x )
            {
                return vec_traits<vec_type>::write_element_idx(i,const_cast<vec_type &>(x));
            }
        
            protected:
        
            static BOOST_QVM_INLINE_TRIVIAL
            scalar_type & write_element_idx( int i, vec_type & m )
            {
                /* unspecified */
            }
        };        
        
        template <class T>
        struct is_mat
        {
            static bool const value=/*unspecified*/;
        };        
        
        template <class M>
        struct mat_traits
        {
            /*main template members unspecified*/
        };
        
        /*
        User-defined (possibly partial) specializations:
        
        template <>
        struct mat_traits<M>
        {
            static int const rows = /*user-defined*/;        
            static int const cols = /*user-defined*/;        
            typedef /*user-defined*/ scalar_type;        
        
            template <int R,int C> static inline scalar_type read_element( Matrix const & m );        
            template <int R,int C> static inline scalar_type & write_element( Matrix & m );        
        
            static inline scalar_type read_element_idx( int r, int c, Matrix const & m );        
            static inline scalar_type & write_element_idx( int r, int c, Matrix & m );        
        };
        */        
        
        template <class MatType,class ScalarType,int Rows,int Cols>
        struct mat_traits_defaults
        {
            typedef MatType mat_type;
            typedef ScalarType scalar_type;
            static int const rows=Rows;
            static int const cols=Cols;
        
            template <int Row,int Col>
            static BOOST_QVM_INLINE_CRITICAL
            scalar_type write_element( mat_type const & x )
            {
                return mat_traits<mat_type>::template write_element<Row,Col>(const_cast<mat_type &>(x));
            }
        
            static BOOST_QVM_INLINE_CRITICAL
            scalar_type read_element_idx( int r, int c, mat_type const & x )
            {
                return mat_traits<mat_type>::write_element_idx(r,c,const_cast<mat_type &>(x));
            }
        
            protected:
        
            static BOOST_QVM_INLINE_TRIVIAL
            scalar_type & write_element_idx( int r, int c, mat_type & m )
            {
                /* unspecified */
            }
        };
        }
    }

See also: Boost QVM | Synopsis