Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-18 09:03:36

0001 #ifndef BOOST_QVM_DETAIL_VEC_ASSIGN_HPP_INCLUDED
0002 #define BOOST_QVM_DETAIL_VEC_ASSIGN_HPP_INCLUDED
0003 
0004 // Copyright 2008-2024 Emil Dotchevski and Reverge Studios, Inc.
0005 // Distributed under the Boost Software License, Version 1.0. (See accompanying
0006 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0007 
0008 #include <boost/qvm/gen/vec_assign2.hpp>
0009 #include <boost/qvm/gen/vec_assign3.hpp>
0010 #include <boost/qvm/gen/vec_assign4.hpp>
0011 
0012 namespace boost { namespace qvm {
0013 
0014 namespace
0015 qvm_detail
0016     {
0017     template <int D>
0018     struct
0019     assign_vv_defined
0020         {
0021         static bool const value=false;
0022         };
0023 
0024     template <int I,int N>
0025     struct
0026     copy_vector_elements
0027         {
0028         template <class A,class B>
0029         static
0030         BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_CRITICAL
0031         typename enable_if_c<
0032             vec_write_element_ref<A>::value,
0033             void>::type
0034         f( A & a, B const & b )
0035             {
0036             vec_traits<A>::template write_element<I>(a) = vec_traits<B>::template read_element<I>(b);
0037             copy_vector_elements<I+1,N>::f(a,b);
0038             }
0039 
0040         template <class A,class B>
0041         static
0042         BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_CRITICAL
0043         typename enable_if_c<
0044             !vec_write_element_ref<A>::value,
0045             void>::type
0046         f( A & a, B const & b )
0047             {
0048             vec_traits<A>::template write_element<I>(a, vec_traits<B>::template read_element<I>(b));
0049             copy_vector_elements<I+1,N>::f(a,b);
0050             }
0051         };
0052 
0053     template <int N>
0054     struct
0055     copy_vector_elements<N,N>
0056         {
0057         template <class A,class B>
0058         static
0059         void
0060         f( A &, B const & )
0061             {
0062             }
0063         };
0064     }
0065 
0066 template <class A,class B>
0067 inline
0068 typename enable_if_c<
0069     is_vec<A>::value && is_vec<B>::value &&
0070     vec_traits<A>::dim==vec_traits<B>::dim &&
0071     !qvm_detail::assign_vv_defined<vec_traits<A>::dim>::value,
0072     A &>::type
0073 assign( A & a, B const & b )
0074     {
0075     qvm_detail::copy_vector_elements<0,vec_traits<A>::dim>::f(a,b);
0076     return a;
0077     }
0078 
0079 } }
0080 
0081 #endif