Back to home page

EIC code displayed by LXR

 
 

    


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

0001 #ifndef BOOST_QVM_QUAT_TRAITS
0002 #define BOOST_QVM_QUAT_TRAITS
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/is_scalar.hpp>
0010 #include <boost/qvm/enable_if.hpp>
0011 #include <boost/qvm/config.hpp>
0012 
0013 namespace boost { namespace qvm {
0014 
0015 template <class Q>
0016 struct
0017 quat_traits
0018     {
0019     typedef void scalar_type;
0020     };
0021 
0022 template <class T>
0023 struct
0024 is_quat
0025     {
0026     static bool const value = is_scalar<typename quat_traits<T>::scalar_type>::value;
0027     };
0028 
0029 namespace
0030 qvm_detail
0031     {
0032     template <class T, T>
0033     struct
0034     qtr_dispatch_yes
0035         {
0036         char x, y;
0037         };
0038     }
0039 
0040 template <class T>
0041 class
0042 quat_write_element_ref
0043     {
0044     template <class U>
0045     static qvm_detail::qtr_dispatch_yes<typename quat_traits<U>::scalar_type & (*)( U & ), &quat_traits<U>::template write_element<0> > check(int);
0046 
0047     template <class>
0048     static char check(long);
0049 
0050     public:
0051 
0052     static bool const value = sizeof(check<T>(0)) > 1;
0053     };
0054 
0055 template <int I, class Q>
0056 BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_CRITICAL
0057 typename enable_if_c<
0058     quat_write_element_ref<Q>::value,
0059     void>::type
0060 write_quat_element( Q & q, typename quat_traits<Q>::scalar_type s )
0061     {
0062     quat_traits<Q>::template write_element<I>(q) = s;
0063     }
0064 
0065 template <int I, class Q>
0066 BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_CRITICAL
0067 typename enable_if_c<
0068     !quat_write_element_ref<Q>::value,
0069     void>::type
0070 write_quat_element( Q & q, typename quat_traits<Q>::scalar_type s )
0071     {
0072     quat_traits<Q>::template write_element<I>(q, s);
0073     }
0074 
0075 template <class Q>
0076 BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_CRITICAL
0077 typename enable_if_c<
0078     quat_write_element_ref<Q>::value,
0079     void>::type
0080 write_quat_element_idx( int i, Q & q, typename quat_traits<Q>::scalar_type s )
0081     {
0082     quat_traits<Q>::template write_element_idx(i, q) = s;
0083     }
0084 
0085 template <class Q>
0086 BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_CRITICAL
0087 typename enable_if_c<
0088     !quat_write_element_ref<Q>::value,
0089     void>::type
0090 write_vec_element_idx( int i, Q & q, typename quat_traits<Q>::scalar_type s )
0091     {
0092     quat_traits<Q>::template write_element_idx(i, q, s);
0093     }
0094 
0095 } }
0096 
0097 #endif