deduce_matrix_test.cpp 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. #include <boost/qvm/deduce_mat.hpp>
  5. template <class T,class U>
  6. struct same_type;
  7. template <class T>
  8. struct
  9. same_type<T,T>
  10. {
  11. };
  12. template <class A,class B,int R,int C,class Result>
  13. struct
  14. check
  15. {
  16. same_type<typename boost::qvm::deduce_mat2<A,B,R,C>::type,Result> a;
  17. same_type<typename boost::qvm::deduce_mat2<B,A,R,C>::type,Result> b;
  18. };
  19. template <class T,int R,int C> struct m;
  20. namespace
  21. boost
  22. {
  23. namespace
  24. qvm
  25. {
  26. template <class T,int R,int C>
  27. struct
  28. mat_traits< m<T,R,C> >
  29. {
  30. typedef T scalar_type;
  31. static int const rows=R;
  32. static int const cols=C;
  33. };
  34. }
  35. }
  36. int
  37. main()
  38. {
  39. same_type< boost::qvm::deduce_mat< m<int,4,2> >::type, m<int,4,2> >();
  40. same_type< boost::qvm::deduce_mat< m<int,4,2>, 4, 4 >::type, boost::qvm::mat<int,4,4> >();
  41. check< m<int,4,2>, m<int,4,2>, 4, 2, m<int,4,2> >();
  42. check< m<int,4,2>, m<float,4,2>, 4, 4, boost::qvm::mat<float,4,4> >();
  43. }