File indexing completed on 2025-09-16 08:49:23
0001 #ifndef BOOST_QVM_SCALAR_TRAITS_HPP_INCLUDED
0002 #define BOOST_QVM_SCALAR_TRAITS_HPP_INCLUDED
0003
0004
0005
0006
0007
0008 #include <boost/qvm/quat_traits.hpp>
0009 #include <boost/qvm/vec_traits.hpp>
0010 #include <boost/qvm/mat_traits.hpp>
0011 #include <boost/qvm/config.hpp>
0012
0013 namespace boost { namespace qvm {
0014
0015 template <class Scalar>
0016 struct
0017 scalar_traits
0018 {
0019 static
0020 BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_CRITICAL
0021 Scalar
0022 value( int v )
0023 {
0024 return Scalar(v);
0025 }
0026 };
0027
0028 namespace
0029 qvm_detail
0030 {
0031 template <class A,
0032 bool IsQ=is_quat<A>::value,
0033 bool IsV=is_vec<A>::value,
0034 bool IsM=is_mat<A>::value,
0035 bool IsS=is_scalar<A>::value>
0036 struct
0037 scalar_impl
0038 {
0039 typedef void type;
0040 };
0041
0042 template <class A>
0043 struct
0044 scalar_impl<A,false,false,false,true>
0045 {
0046 typedef A type;
0047 };
0048
0049 template <class A>
0050 struct
0051 scalar_impl<A,false,false,true,false>
0052 {
0053 typedef typename mat_traits<A>::scalar_type type;
0054 };
0055
0056 template <class A>
0057 struct
0058 scalar_impl<A,false,true,false,false>
0059 {
0060 typedef typename vec_traits<A>::scalar_type type;
0061 };
0062
0063 template <class A>
0064 struct
0065 scalar_impl<A,true,false,false,false>
0066 {
0067 typedef typename quat_traits<A>::scalar_type type;
0068 };
0069 }
0070
0071 template <class A>
0072 struct
0073 scalar
0074 {
0075 typedef typename qvm_detail::scalar_impl<A>::type type;
0076 };
0077
0078 } }
0079
0080 #endif