Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:50:42

0001 #ifndef BOOST_QVM_DETAIL_VEC_ASSIGN_HPP_INCLUDED
0002 #define BOOST_QVM_DETAIL_VEC_ASSIGN_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/gen/vec_assign2.hpp>
0010 #include <boost/qvm/gen/vec_assign3.hpp>
0011 #include <boost/qvm/gen/vec_assign4.hpp>
0012 
0013 namespace boost { namespace qvm {
0014 
0015 namespace
0016 qvm_detail
0017     {
0018     template <int D>
0019     struct
0020     assign_vv_defined
0021         {
0022         static bool const value=false;
0023         };
0024 
0025     template <int I,int N>
0026     struct
0027     copy_vector_elements
0028         {
0029         template <class A,class B>
0030         static
0031         BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_CRITICAL
0032         typename enable_if_c<
0033             vec_write_element_ref<A>::value,
0034             void>::type
0035         f( A & a, B const & b )
0036             {
0037             vec_traits<A>::template write_element<I>(a) = vec_traits<B>::template read_element<I>(b);
0038             copy_vector_elements<I+1,N>::f(a,b);
0039             }
0040 
0041         template <class A,class B>
0042         static
0043         BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_CRITICAL
0044         typename enable_if_c<
0045             !vec_write_element_ref<A>::value,
0046             void>::type
0047         f( A & a, B const & b )
0048             {
0049             vec_traits<A>::template write_element<I>(a, vec_traits<B>::template read_element<I>(b));
0050             copy_vector_elements<I+1,N>::f(a,b);
0051             }
0052         };
0053 
0054     template <int N>
0055     struct
0056     copy_vector_elements<N,N>
0057         {
0058         template <class A,class B>
0059         static
0060         void
0061         f( A &, B const & )
0062             {
0063             }
0064         };
0065     }
0066 
0067 template <class A,class B>
0068 inline
0069 typename enable_if_c<
0070     is_vec<A>::value && is_vec<B>::value &&
0071     vec_traits<A>::dim==vec_traits<B>::dim &&
0072     !qvm_detail::assign_vv_defined<vec_traits<A>::dim>::value,
0073     A &>::type
0074 assign( A & a, B const & b )
0075     {
0076     qvm_detail::copy_vector_elements<0,vec_traits<A>::dim>::f(a,b);
0077     return a;
0078     }
0079 
0080 } }
0081 
0082 #endif