File indexing completed on 2025-01-18 09:51:08
0001 #ifndef BOOST_QVM_VEC_ACCESS_HPP_INCLUDED
0002 #define BOOST_QVM_VEC_ACCESS_HPP_INCLUDED
0003
0004
0005
0006
0007
0008
0009 #include <boost/qvm/vec_traits.hpp>
0010 #include <boost/qvm/config.hpp>
0011 #include <boost/qvm/static_assert.hpp>
0012 #include <boost/qvm/enable_if.hpp>
0013
0014 namespace boost { namespace qvm {
0015
0016 template <class V> BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_TRIVIAL typename enable_if_c<is_vec<V>::value,typename vec_traits<V>::scalar_type>::type X( V const & a ) { BOOST_QVM_STATIC_ASSERT(0<vec_traits<V>::dim); return vec_traits<V>::template read_element<0>(a); }
0017 template <class V> BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_TRIVIAL typename enable_if_c<is_vec<V>::value,typename vec_traits<V>::scalar_type>::type Y( V const & a ) { BOOST_QVM_STATIC_ASSERT(1<vec_traits<V>::dim); return vec_traits<V>::template read_element<1>(a); }
0018 template <class V> BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_TRIVIAL typename enable_if_c<is_vec<V>::value,typename vec_traits<V>::scalar_type>::type Z( V const & a ) { BOOST_QVM_STATIC_ASSERT(2<vec_traits<V>::dim); return vec_traits<V>::template read_element<2>(a); }
0019 template <class V> BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_TRIVIAL typename enable_if_c<is_vec<V>::value,typename vec_traits<V>::scalar_type>::type W( V const & a ) { BOOST_QVM_STATIC_ASSERT(3<vec_traits<V>::dim); return vec_traits<V>::template read_element<3>(a); }
0020
0021 template <class V> BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_TRIVIAL typename enable_if_c<is_vec<V>::value,typename vec_traits<V>::scalar_type>::type A0( V const & a ) { BOOST_QVM_STATIC_ASSERT(0<vec_traits<V>::dim); return vec_traits<V>::template read_element<0>(a); }
0022 template <class V> BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_TRIVIAL typename enable_if_c<is_vec<V>::value,typename vec_traits<V>::scalar_type>::type A1( V const & a ) { BOOST_QVM_STATIC_ASSERT(1<vec_traits<V>::dim); return vec_traits<V>::template read_element<1>(a); }
0023 template <class V> BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_TRIVIAL typename enable_if_c<is_vec<V>::value,typename vec_traits<V>::scalar_type>::type A2( V const & a ) { BOOST_QVM_STATIC_ASSERT(2<vec_traits<V>::dim); return vec_traits<V>::template read_element<2>(a); }
0024 template <class V> BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_TRIVIAL typename enable_if_c<is_vec<V>::value,typename vec_traits<V>::scalar_type>::type A3( V const & a ) { BOOST_QVM_STATIC_ASSERT(3<vec_traits<V>::dim); return vec_traits<V>::template read_element<3>(a); }
0025 template <class V> BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_TRIVIAL typename enable_if_c<is_vec<V>::value,typename vec_traits<V>::scalar_type>::type A4( V const & a ) { BOOST_QVM_STATIC_ASSERT(4<vec_traits<V>::dim); return vec_traits<V>::template read_element<4>(a); }
0026 template <class V> BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_TRIVIAL typename enable_if_c<is_vec<V>::value,typename vec_traits<V>::scalar_type>::type A5( V const & a ) { BOOST_QVM_STATIC_ASSERT(5<vec_traits<V>::dim); return vec_traits<V>::template read_element<5>(a); }
0027 template <class V> BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_TRIVIAL typename enable_if_c<is_vec<V>::value,typename vec_traits<V>::scalar_type>::type A6( V const & a ) { BOOST_QVM_STATIC_ASSERT(6<vec_traits<V>::dim); return vec_traits<V>::template read_element<6>(a); }
0028 template <class V> BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_TRIVIAL typename enable_if_c<is_vec<V>::value,typename vec_traits<V>::scalar_type>::type A7( V const & a ) { BOOST_QVM_STATIC_ASSERT(7<vec_traits<V>::dim); return vec_traits<V>::template read_element<7>(a); }
0029 template <class V> BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_TRIVIAL typename enable_if_c<is_vec<V>::value,typename vec_traits<V>::scalar_type>::type A8( V const & a ) { BOOST_QVM_STATIC_ASSERT(8<vec_traits<V>::dim); return vec_traits<V>::template read_element<8>(a); }
0030 template <class V> BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_TRIVIAL typename enable_if_c<is_vec<V>::value,typename vec_traits<V>::scalar_type>::type A9( V const & a ) { BOOST_QVM_STATIC_ASSERT(9<vec_traits<V>::dim); return vec_traits<V>::template read_element<9>(a); }
0031
0032 namespace
0033 qvm_detail
0034 {
0035 template <int I,class V>
0036 struct
0037 v_element_access
0038 {
0039 BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_CRITICAL
0040 void
0041 operator=( typename vec_traits<V>::scalar_type s )
0042 {
0043 vec_traits<V>::template write_element<I>(*reinterpret_cast<V *>(this), s);
0044 }
0045
0046 BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_CRITICAL
0047 operator typename vec_traits<V>::scalar_type() const
0048 {
0049 return vec_traits<V>::template read_element<I>(*reinterpret_cast<V const *>(this));
0050 }
0051 };
0052 }
0053
0054 template <int I,class V>
0055 BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_TRIVIAL
0056 typename enable_if_c<
0057 is_vec<V>::value,
0058 typename vec_traits<V>::scalar_type>::type
0059 A( V const & a )
0060 {
0061 BOOST_QVM_STATIC_ASSERT(I>=0);
0062 BOOST_QVM_STATIC_ASSERT(I<vec_traits<V>::dim);
0063 return vec_traits<V>::template read_element<I>(a);
0064 }
0065
0066 template <int I,class V>
0067 BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_TRIVIAL
0068 typename enable_if_c<
0069 is_vec<V>::value && vec_write_element_ref<V>::value,
0070 typename vec_traits<V>::scalar_type &>::type
0071 A( V & a )
0072 {
0073 BOOST_QVM_STATIC_ASSERT(I>=0);
0074 BOOST_QVM_STATIC_ASSERT(I<vec_traits<V>::dim);
0075 return vec_traits<V>::template write_element<I>(a);
0076 }
0077
0078 template <int I,class V>
0079 BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_TRIVIAL
0080 typename enable_if_c<
0081 is_vec<V>::value && !vec_write_element_ref<V>::value,
0082 qvm_detail::v_element_access<I,V> &>::type
0083 A( V & a )
0084 {
0085 BOOST_QVM_STATIC_ASSERT(I>=0);
0086 BOOST_QVM_STATIC_ASSERT(I<vec_traits<V>::dim);
0087 return *reinterpret_cast<qvm_detail::v_element_access<I,V> *>(&a);
0088 }
0089
0090 template <class V> BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_TRIVIAL typename enable_if_c<is_vec<V>::value && vec_write_element_ref<V>::value,typename vec_traits<V>::scalar_type &>::type X( V & a ) { BOOST_QVM_STATIC_ASSERT(0<vec_traits<V>::dim); return vec_traits<V>::template write_element<0>(a); }
0091 template <class V> BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_TRIVIAL typename enable_if_c<is_vec<V>::value && vec_write_element_ref<V>::value,typename vec_traits<V>::scalar_type &>::type Y( V & a ) { BOOST_QVM_STATIC_ASSERT(1<vec_traits<V>::dim); return vec_traits<V>::template write_element<1>(a); }
0092 template <class V> BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_TRIVIAL typename enable_if_c<is_vec<V>::value && vec_write_element_ref<V>::value,typename vec_traits<V>::scalar_type &>::type Z( V & a ) { BOOST_QVM_STATIC_ASSERT(2<vec_traits<V>::dim); return vec_traits<V>::template write_element<2>(a); }
0093 template <class V> BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_TRIVIAL typename enable_if_c<is_vec<V>::value && vec_write_element_ref<V>::value,typename vec_traits<V>::scalar_type &>::type W( V & a ) { BOOST_QVM_STATIC_ASSERT(3<vec_traits<V>::dim); return vec_traits<V>::template write_element<3>(a); }
0094
0095 template <class V> BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_TRIVIAL typename enable_if_c<is_vec<V>::value && vec_write_element_ref<V>::value,typename vec_traits<V>::scalar_type &>::type A0( V & a ) { BOOST_QVM_STATIC_ASSERT(0<vec_traits<V>::dim); return vec_traits<V>::template write_element<0>(a); }
0096 template <class V> BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_TRIVIAL typename enable_if_c<is_vec<V>::value && vec_write_element_ref<V>::value,typename vec_traits<V>::scalar_type &>::type A1( V & a ) { BOOST_QVM_STATIC_ASSERT(1<vec_traits<V>::dim); return vec_traits<V>::template write_element<1>(a); }
0097 template <class V> BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_TRIVIAL typename enable_if_c<is_vec<V>::value && vec_write_element_ref<V>::value,typename vec_traits<V>::scalar_type &>::type A2( V & a ) { BOOST_QVM_STATIC_ASSERT(2<vec_traits<V>::dim); return vec_traits<V>::template write_element<2>(a); }
0098 template <class V> BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_TRIVIAL typename enable_if_c<is_vec<V>::value && vec_write_element_ref<V>::value,typename vec_traits<V>::scalar_type &>::type A3( V & a ) { BOOST_QVM_STATIC_ASSERT(3<vec_traits<V>::dim); return vec_traits<V>::template write_element<3>(a); }
0099 template <class V> BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_TRIVIAL typename enable_if_c<is_vec<V>::value && vec_write_element_ref<V>::value,typename vec_traits<V>::scalar_type &>::type A4( V & a ) { BOOST_QVM_STATIC_ASSERT(4<vec_traits<V>::dim); return vec_traits<V>::template write_element<4>(a); }
0100 template <class V> BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_TRIVIAL typename enable_if_c<is_vec<V>::value && vec_write_element_ref<V>::value,typename vec_traits<V>::scalar_type &>::type A5( V & a ) { BOOST_QVM_STATIC_ASSERT(5<vec_traits<V>::dim); return vec_traits<V>::template write_element<5>(a); }
0101 template <class V> BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_TRIVIAL typename enable_if_c<is_vec<V>::value && vec_write_element_ref<V>::value,typename vec_traits<V>::scalar_type &>::type A6( V & a ) { BOOST_QVM_STATIC_ASSERT(6<vec_traits<V>::dim); return vec_traits<V>::template write_element<6>(a); }
0102 template <class V> BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_TRIVIAL typename enable_if_c<is_vec<V>::value && vec_write_element_ref<V>::value,typename vec_traits<V>::scalar_type &>::type A7( V & a ) { BOOST_QVM_STATIC_ASSERT(7<vec_traits<V>::dim); return vec_traits<V>::template write_element<7>(a); }
0103 template <class V> BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_TRIVIAL typename enable_if_c<is_vec<V>::value && vec_write_element_ref<V>::value,typename vec_traits<V>::scalar_type &>::type A8( V & a ) { BOOST_QVM_STATIC_ASSERT(8<vec_traits<V>::dim); return vec_traits<V>::template write_element<8>(a); }
0104 template <class V> BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_TRIVIAL typename enable_if_c<is_vec<V>::value && vec_write_element_ref<V>::value,typename vec_traits<V>::scalar_type &>::type A9( V & a ) { BOOST_QVM_STATIC_ASSERT(9<vec_traits<V>::dim); return vec_traits<V>::template write_element<9>(a); }
0105
0106 template <class V> BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_TRIVIAL typename enable_if_c<is_vec<V>::value && !vec_write_element_ref<V>::value,qvm_detail::v_element_access<0,V> &>::type X( V & a ) { BOOST_QVM_STATIC_ASSERT(0<vec_traits<V>::dim); return *reinterpret_cast<qvm_detail::v_element_access<0, V> *>(&a); }
0107 template <class V> BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_TRIVIAL typename enable_if_c<is_vec<V>::value && !vec_write_element_ref<V>::value,qvm_detail::v_element_access<1,V> &>::type Y( V & a ) { BOOST_QVM_STATIC_ASSERT(1<vec_traits<V>::dim); return *reinterpret_cast<qvm_detail::v_element_access<1, V> *>(&a); }
0108 template <class V> BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_TRIVIAL typename enable_if_c<is_vec<V>::value && !vec_write_element_ref<V>::value,qvm_detail::v_element_access<2,V> &>::type Z( V & a ) { BOOST_QVM_STATIC_ASSERT(2<vec_traits<V>::dim); return *reinterpret_cast<qvm_detail::v_element_access<2, V> *>(&a); }
0109 template <class V> BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_TRIVIAL typename enable_if_c<is_vec<V>::value && !vec_write_element_ref<V>::value,qvm_detail::v_element_access<3,V> &>::type W( V & a ) { BOOST_QVM_STATIC_ASSERT(3<vec_traits<V>::dim); return *reinterpret_cast<qvm_detail::v_element_access<3, V> *>(&a); }
0110
0111 template <class V> BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_TRIVIAL typename enable_if_c<is_vec<V>::value && !vec_write_element_ref<V>::value,qvm_detail::v_element_access<0,V> &>::type A0( V & a ) { BOOST_QVM_STATIC_ASSERT(0<vec_traits<V>::dim); return *reinterpret_cast<qvm_detail::v_element_access<0, V> *>(&a); }
0112 template <class V> BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_TRIVIAL typename enable_if_c<is_vec<V>::value && !vec_write_element_ref<V>::value,qvm_detail::v_element_access<1,V> &>::type A1( V & a ) { BOOST_QVM_STATIC_ASSERT(1<vec_traits<V>::dim); return *reinterpret_cast<qvm_detail::v_element_access<1, V> *>(&a); }
0113 template <class V> BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_TRIVIAL typename enable_if_c<is_vec<V>::value && !vec_write_element_ref<V>::value,qvm_detail::v_element_access<2,V> &>::type A2( V & a ) { BOOST_QVM_STATIC_ASSERT(2<vec_traits<V>::dim); return *reinterpret_cast<qvm_detail::v_element_access<2, V> *>(&a); }
0114 template <class V> BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_TRIVIAL typename enable_if_c<is_vec<V>::value && !vec_write_element_ref<V>::value,qvm_detail::v_element_access<3,V> &>::type A3( V & a ) { BOOST_QVM_STATIC_ASSERT(3<vec_traits<V>::dim); return *reinterpret_cast<qvm_detail::v_element_access<3, V> *>(&a); }
0115 template <class V> BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_TRIVIAL typename enable_if_c<is_vec<V>::value && !vec_write_element_ref<V>::value,qvm_detail::v_element_access<4,V> &>::type A4( V & a ) { BOOST_QVM_STATIC_ASSERT(4<vec_traits<V>::dim); return *reinterpret_cast<qvm_detail::v_element_access<4, V> *>(&a); }
0116 template <class V> BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_TRIVIAL typename enable_if_c<is_vec<V>::value && !vec_write_element_ref<V>::value,qvm_detail::v_element_access<5,V> &>::type A5( V & a ) { BOOST_QVM_STATIC_ASSERT(5<vec_traits<V>::dim); return *reinterpret_cast<qvm_detail::v_element_access<5, V> *>(&a); }
0117 template <class V> BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_TRIVIAL typename enable_if_c<is_vec<V>::value && !vec_write_element_ref<V>::value,qvm_detail::v_element_access<6,V> &>::type A6( V & a ) { BOOST_QVM_STATIC_ASSERT(6<vec_traits<V>::dim); return *reinterpret_cast<qvm_detail::v_element_access<6, V> *>(&a); }
0118 template <class V> BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_TRIVIAL typename enable_if_c<is_vec<V>::value && !vec_write_element_ref<V>::value,qvm_detail::v_element_access<7,V> &>::type A7( V & a ) { BOOST_QVM_STATIC_ASSERT(7<vec_traits<V>::dim); return *reinterpret_cast<qvm_detail::v_element_access<7, V> *>(&a); }
0119 template <class V> BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_TRIVIAL typename enable_if_c<is_vec<V>::value && !vec_write_element_ref<V>::value,qvm_detail::v_element_access<8,V> &>::type A8( V & a ) { BOOST_QVM_STATIC_ASSERT(8<vec_traits<V>::dim); return *reinterpret_cast<qvm_detail::v_element_access<8, V> *>(&a); }
0120 template <class V> BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_TRIVIAL typename enable_if_c<is_vec<V>::value && !vec_write_element_ref<V>::value,qvm_detail::v_element_access<9,V> &>::type A9( V & a ) { BOOST_QVM_STATIC_ASSERT(9<vec_traits<V>::dim); return *reinterpret_cast<qvm_detail::v_element_access<9, V> *>(&a); }
0121
0122 } }
0123
0124 #endif