Back to home page

EIC code displayed by LXR

 
 

    


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

0001 // Copyright 2008-2022 Emil Dotchevski and Reverge Studios, Inc.
0002 
0003 // Distributed under the Boost Software License, Version 1.0. (See accompanying
0004 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0005 
0006 #ifndef BOOST_QVM_VEC_TRAITS_HPP_INCLUDED
0007 #define BOOST_QVM_VEC_TRAITS_HPP_INCLUDED
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 V>
0016 struct
0017 vec_traits
0018     {
0019     static int const dim=0;
0020     typedef void scalar_type;
0021     };
0022 
0023 template <class T>
0024 struct
0025 is_vec
0026     {
0027     static bool const value = is_scalar<typename vec_traits<T>::scalar_type>::value && vec_traits<T>::dim>0;
0028     };
0029 
0030 namespace
0031 qvm_detail
0032     {
0033     template <class T, T>
0034     struct
0035     vtr_dispatch_yes
0036         {
0037         char x, y;
0038         };
0039     }
0040 
0041 template <class T>
0042 class
0043 vec_write_element_ref
0044     {
0045     template <class U>
0046     static qvm_detail::vtr_dispatch_yes<typename vec_traits<U>::scalar_type & (*)( U & ), &vec_traits<U>::template write_element<0> > check(int);
0047 
0048     template <class>
0049     static char check(long);
0050 
0051     public:
0052 
0053     static bool const value = sizeof(check<T>(0)) > 1;
0054     };
0055 
0056 template <int I, class V>
0057 BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_CRITICAL
0058 typename enable_if_c<
0059     vec_write_element_ref<V>::value,
0060     void>::type
0061 write_vec_element( V & v, typename vec_traits<V>::scalar_type s )
0062     {
0063     vec_traits<V>::template write_element<I>(v) = s;
0064     }
0065 
0066 template <int I, class V>
0067 BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_CRITICAL
0068 typename enable_if_c<
0069     !vec_write_element_ref<V>::value,
0070     void>::type
0071 write_vec_element( V & v, typename vec_traits<V>::scalar_type s )
0072     {
0073     vec_traits<V>::template write_element<I>(v, s);
0074     }
0075 
0076 template <class V>
0077 BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_CRITICAL
0078 typename enable_if_c<
0079     vec_write_element_ref<V>::value,
0080     void>::type
0081 write_vec_element_idx( int i, V & v, typename vec_traits<V>::scalar_type s )
0082     {
0083     vec_traits<V>::write_element_idx(i, v) = s;
0084     }
0085 
0086 template <class V>
0087 BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_CRITICAL
0088 typename enable_if_c<
0089     !vec_write_element_ref<V>::value,
0090     void>::type
0091 write_vec_element_idx( int i, V & v, typename vec_traits<V>::scalar_type s )
0092     {
0093     vec_traits<V>::write_element_idx(i, v, s);
0094     }
0095 
0096 } }
0097 
0098 #endif