vec_assign.hpp 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #ifndef BOOST_QVM_DETAIL_VEC_ASSIGN_HPP_INCLUDED
  2. #define BOOST_QVM_DETAIL_VEC_ASSIGN_HPP_INCLUDED
  3. /// Copyright (c) 2008-2021 Emil Dotchevski and Reverge Studios, Inc.
  4. /// Distributed under the Boost Software License, Version 1.0. (See accompanying
  5. /// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. #include <boost/qvm/gen/vec_assign2.hpp>
  7. #include <boost/qvm/gen/vec_assign3.hpp>
  8. #include <boost/qvm/gen/vec_assign4.hpp>
  9. namespace boost { namespace qvm {
  10. namespace
  11. qvm_detail
  12. {
  13. template <int D>
  14. struct
  15. assign_vv_defined
  16. {
  17. static bool const value=false;
  18. };
  19. template <int I,int N>
  20. struct
  21. copy_vector_elements
  22. {
  23. template <class A,class B>
  24. static
  25. void
  26. f( A & a, B const & b )
  27. {
  28. vec_traits<A>::template write_element<I>(a)=vec_traits<B>::template read_element<I>(b);
  29. copy_vector_elements<I+1,N>::f(a,b);
  30. }
  31. };
  32. template <int N>
  33. struct
  34. copy_vector_elements<N,N>
  35. {
  36. template <class A,class B>
  37. static
  38. void
  39. f( A &, B const & )
  40. {
  41. }
  42. };
  43. }
  44. template <class A,class B>
  45. inline
  46. typename enable_if_c<
  47. is_vec<A>::value && is_vec<B>::value &&
  48. vec_traits<A>::dim==vec_traits<B>::dim &&
  49. !qvm_detail::assign_vv_defined<vec_traits<A>::dim>::value,
  50. A &>::type
  51. assign( A & a, B const & b )
  52. {
  53. qvm_detail::copy_vector_elements<0,vec_traits<A>::dim>::f(a,b);
  54. return a;
  55. }
  56. } }
  57. #endif