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_ARRAY_HPP_INCLUDED
0002 #define BOOST_QVM_QUAT_TRAITS_ARRAY_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/config.hpp>
0010 #include <boost/qvm/deduce_quat.hpp>
0011 #include <boost/qvm/assert.hpp>
0012 
0013 #if __cplusplus > 199711L
0014 
0015 #include <array>
0016 
0017 namespace boost { namespace qvm {
0018 
0019 template <class T,std::size_t D>
0020 struct
0021 quat_traits<std::array<T,D>>
0022     {
0023     typedef void scalar_type;
0024     };
0025 template <class T,std::size_t D>
0026 struct
0027 quat_traits<std::array<std::array<T,D>,4> >
0028     {
0029     typedef void scalar_type;
0030     };
0031 template <class T,std::size_t D>
0032 struct
0033 quat_traits<std::array<std::array<T,4>,D> >
0034     {
0035     typedef void scalar_type;
0036     };
0037 template <class T>
0038 struct
0039 quat_traits<std::array<std::array<T,4>,4> >
0040     {
0041     typedef void scalar_type;
0042     };
0043 template <class T,std::size_t M,std::size_t N>
0044 struct
0045 quat_traits<std::array<std::array<T,M>,N> >
0046     {
0047     typedef void scalar_type;
0048     };
0049 
0050 template <class T>
0051 struct
0052 quat_traits<std::array<T,4> >
0053     {
0054     typedef std::array<T,4> this_quaternion;
0055     typedef T scalar_type;
0056 
0057     template <int I>
0058     static
0059     BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_CRITICAL
0060     scalar_type
0061     read_element( this_quaternion const & x )
0062         {
0063         BOOST_QVM_STATIC_ASSERT(I>=0);
0064         BOOST_QVM_STATIC_ASSERT(I<4);
0065         return x[I];
0066         }
0067 
0068     template <int I>
0069     static
0070     BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_CRITICAL
0071     scalar_type &
0072     write_element( this_quaternion & x )
0073         {
0074         BOOST_QVM_STATIC_ASSERT(I>=0);
0075         BOOST_QVM_STATIC_ASSERT(I<4);
0076         return x[I];
0077         }
0078 
0079     static
0080     BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_CRITICAL
0081     scalar_type
0082     read_element_idx( int i, this_quaternion const & x )
0083         {
0084         BOOST_QVM_ASSERT(i>=0);
0085         BOOST_QVM_ASSERT(i<4);
0086         return x[i];
0087         }
0088 
0089     static
0090     BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_CRITICAL
0091     scalar_type &
0092     write_element_idx( int i, this_quaternion & x )
0093         {
0094         BOOST_QVM_ASSERT(i>=0);
0095         BOOST_QVM_ASSERT(i<4);
0096         return x[i];
0097         }
0098     };
0099 
0100 template <class T>
0101 struct
0102 quat_traits<std::array<T,4> const>
0103     {
0104     typedef std::array<T,4> const this_quaternion;
0105     typedef T scalar_type;
0106 
0107     template <int I>
0108     static
0109     BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_CRITICAL
0110     scalar_type
0111     read_element( this_quaternion & x )
0112         {
0113         BOOST_QVM_STATIC_ASSERT(I>=0);
0114         BOOST_QVM_STATIC_ASSERT(I<4);
0115         return x[I];
0116         }
0117 
0118     static
0119     BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_CRITICAL
0120     scalar_type
0121     read_element_idx( int i, this_quaternion & x )
0122         {
0123         BOOST_QVM_ASSERT(i>=0);
0124         BOOST_QVM_ASSERT(i<4);
0125         return x[i];
0126         }
0127     };
0128 
0129 template <class T>
0130 struct
0131 deduce_quat<std::array<T,4> >
0132     {
0133     typedef quat<T> type;
0134     };
0135 
0136 template <class T>
0137 struct
0138 deduce_quat<std::array<T,4> const>
0139     {
0140     typedef quat<T> type;
0141     };
0142 
0143 template <class T1,class T2>
0144 struct
0145 deduce_quat2<std::array<T1,4>,std::array<T2,4> >
0146     {
0147     typedef quat<typename deduce_scalar<T1,T2>::type> type;
0148     };
0149 
0150 template <class T1,class T2>
0151 struct
0152 deduce_quat2<std::array<T1,4> const,std::array<T2,4> >
0153     {
0154     typedef quat<typename deduce_scalar<T1,T2>::type> type;
0155     };
0156 
0157 template <class T1,class T2>
0158 struct
0159 deduce_quat2<std::array<T1,4>,std::array<T2,4> const>
0160     {
0161     typedef quat<typename deduce_scalar<T1,T2>::type> type;
0162     };
0163 
0164 template <class T1,class T2>
0165 struct
0166 deduce_quat2<std::array<T1,4> const,std::array<T2,4> const>
0167     {
0168     typedef quat<typename deduce_scalar<T1,T2>::type> type;
0169     };
0170 
0171 } }
0172 
0173 #endif
0174 
0175 namespace boost { namespace qvm {
0176 
0177 template <class T,int D>
0178 struct
0179 quat_traits<T[D]>
0180     {
0181     typedef void scalar_type;
0182     };
0183 template <class T,int D>
0184 struct
0185 quat_traits<T[D][4]>
0186     {
0187     typedef void scalar_type;
0188     };
0189 template <class T,int D>
0190 struct
0191 quat_traits<T[4][D]>
0192     {
0193     typedef void scalar_type;
0194     };
0195 template <class T>
0196 struct
0197 quat_traits<T[4][4]>
0198     {
0199     typedef void scalar_type;
0200     };
0201 template <class T,int M,int N>
0202 struct
0203 quat_traits<T[M][N]>
0204     {
0205     typedef void scalar_type;
0206     };
0207 
0208 template <class T>
0209 struct
0210 quat_traits<T[4]>
0211     {
0212     typedef T this_quaternion[4];
0213     typedef T scalar_type;
0214 
0215     template <int I>
0216     static
0217     BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_CRITICAL
0218     scalar_type
0219     read_element( this_quaternion const & x )
0220         {
0221         BOOST_QVM_STATIC_ASSERT(I>=0);
0222         BOOST_QVM_STATIC_ASSERT(I<4);
0223         return x[I];
0224         }
0225 
0226     template <int I>
0227     static
0228     BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_CRITICAL
0229     scalar_type &
0230     write_element( this_quaternion & x )
0231         {
0232         BOOST_QVM_STATIC_ASSERT(I>=0);
0233         BOOST_QVM_STATIC_ASSERT(I<4);
0234         return x[I];
0235         }
0236 
0237     static
0238     BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_CRITICAL
0239     scalar_type
0240     read_element_idx( int i, this_quaternion const & x )
0241         {
0242         BOOST_QVM_ASSERT(i>=0);
0243         BOOST_QVM_ASSERT(i<4);
0244         return x[i];
0245         }
0246 
0247     static
0248     BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_CRITICAL
0249     scalar_type &
0250     write_element_idx( int i, this_quaternion & x )
0251         {
0252         BOOST_QVM_ASSERT(i>=0);
0253         BOOST_QVM_ASSERT(i<4);
0254         return x[i];
0255         }
0256     };
0257 
0258 template <class T>
0259 struct
0260 deduce_quat<T[4]>
0261     {
0262     typedef quat<T> type;
0263     };
0264 
0265 template <class T>
0266 struct
0267 deduce_quat<T const[4]>
0268     {
0269     typedef quat<T> type;
0270     };
0271 
0272 template <class T1,class T2>
0273 struct
0274 deduce_quat2<T1[4],T2[4]>
0275     {
0276     typedef quat<typename deduce_scalar<T1,T2>::type> type;
0277     };
0278 
0279 template <class T>
0280 T (&ptr_qref( T * ptr ))[4]
0281     {
0282     return *reinterpret_cast<T (*)[4]>(ptr);
0283     }
0284 
0285 } }
0286 
0287 #endif