deduce_vector_test.cpp 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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_vec.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 D,class Result>
  13. struct
  14. check
  15. {
  16. same_type<typename boost::qvm::deduce_vec2<A,B,D>::type,Result> a;
  17. same_type<typename boost::qvm::deduce_vec2<B,A,D>::type,Result> b;
  18. };
  19. template <class T,int D> struct v;
  20. namespace
  21. boost
  22. {
  23. namespace
  24. qvm
  25. {
  26. template <class T,int D>
  27. struct
  28. vec_traits< v<T,D> >
  29. {
  30. typedef T scalar_type;
  31. static int const dim=D;
  32. };
  33. }
  34. }
  35. int
  36. main()
  37. {
  38. same_type< boost::qvm::deduce_vec< v<int,3> >::type, v<int,3> >();
  39. same_type< boost::qvm::deduce_vec< v<int,3>, 4 >::type, boost::qvm::vec<int,4> >();
  40. check< v<int,3>, v<int,3>, 3, v<int,3> >();
  41. check< v<int,3>, v<float,3>, 4, boost::qvm::vec<float,4> >();
  42. }