• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //Copyright (c) 2008-2016 Emil Dotchevski and Reverge Studios, Inc.
2 
3 //Distributed under the Boost Software License, Version 1.0. (See accompanying
4 //file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
5 
6 #include <boost/qvm/vec_operations.hpp>
7 #include <boost/qvm/vec.hpp>
8 #include "test_qvm_vector.hpp"
9 
10 namespace
11     {
12     template <class T,class U>
13     struct same_type;
14 
15     template <class T>
16     struct
17     same_type<T,T>
18         {
19         };
20 
21     template <class T,class U>
22     void
check_deduction(T const &,U const &)23     check_deduction( T const &, U const & )
24         {
25         same_type<T,typename boost::qvm::deduce_vec<U>::type>();
26         }
27 
28     template <int Dim>
29     void
test()30     test()
31         {
32         using namespace boost::qvm;
33         test_qvm::vector<V1,Dim> v1=zero_vec<float,Dim>();
34         for( int i=0; i!=Dim; ++i )
35                 BOOST_TEST(!v1.a[i]);
36         test_qvm::vector<V2,Dim> v2(42,1);
37         set_zero(v2);
38         for( int i=0; i!=Dim; ++i )
39                 BOOST_TEST(!v2.a[i]);
40         check_deduction(vec<float,Dim>(),zero_vec<float,Dim>());
41         check_deduction(vec<int,Dim>(),zero_vec<int,Dim>());
42         }
43     }
44 
45 int
main()46 main()
47     {
48     test<2>();
49     test<3>();
50     test<4>();
51     test<5>();
52     return boost::report_errors();
53     }
54