vec_assign.hpp 1.9 KB

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