Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:51:08

0001 #ifndef BOOST_QVM_SCALAR_TRAITS_HPP_INCLUDED
0002 #define BOOST_QVM_SCALAR_TRAITS_HPP_INCLUDED
0003 
0004 // Copyright 2008-2022 Emil Dotchevski and Reverge Studios, Inc.
0005 
0006 // Distributed under the Boost Software License, Version 1.0. (See accompanying
0007 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0008 
0009 #include <boost/qvm/quat_traits.hpp>
0010 #include <boost/qvm/vec_traits.hpp>
0011 #include <boost/qvm/mat_traits.hpp>
0012 #include <boost/qvm/config.hpp>
0013 
0014 namespace boost { namespace qvm {
0015 
0016 template <class Scalar>
0017 struct
0018 scalar_traits
0019     {
0020     static
0021     BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_CRITICAL
0022     Scalar
0023     value( int v )
0024         {
0025         return Scalar(v);
0026         }
0027     };
0028 
0029 namespace
0030 qvm_detail
0031     {
0032     template <class A,
0033         bool IsQ=is_quat<A>::value,
0034         bool IsV=is_vec<A>::value,
0035         bool IsM=is_mat<A>::value,
0036         bool IsS=is_scalar<A>::value>
0037     struct
0038     scalar_impl
0039         {
0040         typedef void type;
0041         };
0042 
0043     template <class A>
0044     struct
0045     scalar_impl<A,false,false,false,true>
0046         {
0047         typedef A type;
0048         };
0049 
0050     template <class A>
0051     struct
0052     scalar_impl<A,false,false,true,false>
0053         {
0054         typedef typename mat_traits<A>::scalar_type type;
0055         };
0056 
0057     template <class A>
0058     struct
0059     scalar_impl<A,false,true,false,false>
0060         {
0061         typedef typename vec_traits<A>::scalar_type type;
0062         };
0063 
0064     template <class A>
0065     struct
0066     scalar_impl<A,true,false,false,false>
0067         {
0068         typedef typename quat_traits<A>::scalar_type type;
0069         };
0070     }
0071 
0072 template <class A>
0073 struct
0074 scalar
0075     {
0076     typedef typename qvm_detail::scalar_impl<A>::type type;
0077     };
0078 
0079 } }
0080 
0081 #endif